Skip to content

Commit

Permalink
Adding syntax highlighting to README.
Browse files Browse the repository at this point in the history
  • Loading branch information
spoletto committed Jul 18, 2012
1 parent e5a9cae commit 2942e79
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions README.md
Expand Up @@ -18,37 +18,45 @@ Include SPUserResizableView.h and SPUserResizableView.m in your project.

You'll need to #import the SPUserResizableView.h header and construct a new instance of SPUserResizableView. Then, set the contentView on the SPUserResizableView to the view you'd like the user to interact with.

#import "SPUserResizableView.h"
``` objective-c
#import "SPUserResizableView.h"

...
...

- (void)viewDidLoad {
CGRect frame = CGRectMake(50, 50, 200, 150);
SPUserResizableView *userResizableView = [[SPUserResizableView alloc] initWithFrame:frame];
UIView *contentView = [[UIView alloc] initWithFrame:frame];
[contentView setBackgroundColor:[UIColor redColor]];
userResizableView.contentView = contentView;
[self.view addSubview:userResizableView];
[contentView release];
[userResizableView release];
}
- (void)viewDidLoad {
CGRect frame = CGRectMake(50, 50, 200, 150);
SPUserResizableView *userResizableView = [[SPUserResizableView alloc] initWithFrame:frame];
UIView *contentView = [[UIView alloc] initWithFrame:frame];
[contentView setBackgroundColor:[UIColor redColor]];
userResizableView.contentView = contentView;
[self.view addSubview:userResizableView];
[contentView release];
[userResizableView release];
}
```

If you'd like to receive callbacks when the SPUserResizableView receives touchBegan:, touchesEnded: and touchesCancelled: messages, set the delegate on the SPUserResizableView accordingly.

userResizableView.delegate = self;
``` objective-c
userResizableView.delegate = self;
```

Then implement the following delegate methods.

- (void)userResizableViewDidBeginEditing:(SPUserResizableView *)userResizableView;
- (void)userResizableViewDidEndEditing:(SPUserResizableView *)userResizableView;
``` objective-c
- (void)userResizableViewDidBeginEditing:(SPUserResizableView *)userResizableView;
- (void)userResizableViewDidEndEditing:(SPUserResizableView *)userResizableView;
```

By default, SPUserResizableView will show the editing handles (as seen in the screenshot above) whenever it receives a touch event. The editing handles will remain visible even after the userResizableViewDidEndEditing: message is sent. This is to provide visual feedback to the user that the view is indeed moveable and resizable. If you'd like to dismiss the editing handles, you must explicitly call -hideEditingHandles.

The SPUserResizableView is customizable using the following properties:

@property (nonatomic) CGFloat minWidth;
@property (nonatomic) CGFloat minHeight;
@property (nonatomic) BOOL preventsPositionOutsideSuperview;
``` objective-c
@property (nonatomic) CGFloat minWidth;
@property (nonatomic) CGFloat minHeight;
@property (nonatomic) BOOL preventsPositionOutsideSuperview;
```

For an example of how to use SPUserResizableView, please see the included example project.

0 comments on commit 2942e79

Please sign in to comment.