Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spoletto/SPUserResizableView
SPUserResizableView is a user-resizable, user-repositionable UIView subclass built for iOS.
https://github.com/spoletto/SPUserResizableView
Last synced: about 1 month ago
JSON representation
SPUserResizableView is a user-resizable, user-repositionable UIView subclass built for iOS.
- Host: GitHub
- URL: https://github.com/spoletto/SPUserResizableView
- Owner: spoletto
- License: mit
- Created: 2011-12-11T03:30:27.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2017-04-16T19:43:04.000Z (over 7 years ago)
- Last Synced: 2023-11-07T15:14:58.341Z (about 1 year ago)
- Language: Objective-C
- Homepage:
- Size: 414 KB
- Stars: 317
- Watchers: 23
- Forks: 86
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - SPUserResizableView - SPUserResizableView is a user-resizable, user-repositionable UIView subclass built for iOS. (etc)
- awesome - SPUserResizableView - SPUserResizableView is a user-resizable, user-repositionable UIView subclass built for iOS. (etc)
README
SPUserResizableView
===============SPUserResizableView is a user-resizable, user-repositionable UIView subclass. It is modeled after the resizable image view from the Pages iOS app. Any UIView can be provided as the content view for the SPUserResizableView. As the view is respositioned and resized, setFrame: will be called on the content view accordingly.
Screenshot
----
![SPUserResizableView](http://i.imgur.com/krBjw.png)How To Use It
-------------### Installation
Include SPUserResizableView.h and SPUserResizableView.m in your project.
### Setting up the SPUserResizableView
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.
``` 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];
}
```If you'd like to receive callbacks when the SPUserResizableView receives touchBegan:, touchesEnded: and touchesCancelled: messages, set the delegate on the SPUserResizableView accordingly.
``` objective-c
userResizableView.delegate = self;
```Then implement the following delegate methods.
``` 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:
``` 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.