Skip to content

Commit

Permalink
Added properties for readonly access to rotation transform, zoomed cr…
Browse files Browse the repository at this point in the history
…op rect values, and ability to enable/disable rotation.
  • Loading branch information
dimitar-lazarov committed Jun 26, 2014
1 parent b097d8c commit a6e5d9e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Lib/PECropViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

@property (nonatomic) BOOL toolbarHidden;

@property (nonatomic, assign, getter = isRotationEnabled) BOOL rotationEnabled;

@property (nonatomic, readonly) CGAffineTransform rotationTransform;

@property (nonatomic, readonly) CGRect zoomedCropRect;


- (void)resetCropRect;
- (void)resetCropRectAnimated:(BOOL)animated;

Expand Down
51 changes: 51 additions & 0 deletions Lib/PECropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ @interface PECropViewController () <UIActionSheetDelegate>
@property (nonatomic) PECropView *cropView;
@property (nonatomic) UIActionSheet *actionSheet;

- (void)commonInit;

@end

@implementation PECropViewController
@synthesize rotationEnabled = _rotationEnabled;

+ (NSBundle *)bundle
{
Expand All @@ -35,6 +38,31 @@ + (NSBundle *)bundle
return [[PECropViewController bundle] localizedStringForKey:key value:nil table:@"Localizable"];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];

if (self) {
[self commonInit];
}

return self;
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {
[self commonInit];
}

return self;
}

- (void)commonInit {
self.rotationEnabled = YES;
}

#pragma mark -

- (void)loadView
Expand Down Expand Up @@ -75,6 +103,8 @@ - (void)viewDidLoad
self.navigationController.toolbarHidden = self.toolbarHidden;

self.cropView.image = self.image;

self.cropView.rotationGestureRecognizer.enabled = _rotationEnabled;
}

- (void)viewDidAppear:(BOOL)animated
Expand Down Expand Up @@ -142,6 +172,27 @@ - (void)setImageCropRect:(CGRect)imageCropRect
self.cropView.imageCropRect = imageCropRect;
}

- (BOOL)isRotationEnabled
{
return _rotationEnabled;
}

- (void)setRotationEnabled:(BOOL)rotationEnabled
{
_rotationEnabled = rotationEnabled;
self.cropView.rotationGestureRecognizer.enabled = _rotationEnabled;
}

- (CGAffineTransform)rotationTransform
{
return self.cropView.rotation;
}

- (CGRect)zoomedCropRect
{
return self.cropView.zoomedCropRect;
}

- (void)resetCropRect
{
[self.cropView resetCropRect];
Expand Down

0 comments on commit a6e5d9e

Please sign in to comment.