Skip to content

Commit

Permalink
Merge pull request #22 from itouch2/dev
Browse files Browse the repository at this point in the history
modify podspec
itouch2 committed May 20, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 3aa4734 + b6ce48a commit 97577e0
Showing 6 changed files with 44 additions and 16 deletions.
4 changes: 2 additions & 2 deletions PhotoTweaks.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |spec|
spec.name = 'PhotoTweaks'
spec.version = '1.0.2'
spec.version = '1.0.3'
spec.license = 'MIT'
spec.homepage = 'https://github.com/itouch2/PhotoTweaks'
spec.authors = {'Tu You' => '[email protected]'}
spec.summary = 'Drag, Rotate, Scale and Crop.'
spec.source = {:git => 'https://github.com/itouch2/PhotoTweaks.git', :tag => '1.0.2'}
spec.source = {:git => 'https://github.com/itouch2/PhotoTweaks.git', :tag => '1.0.3'}
spec.source_files = 'PhotoTweaks/PhotoTweaks/*.{h,m}'
spec.framework = 'Foundation', 'CoreGraphics', 'UIKit'
spec.requires_arc = true
1 change: 1 addition & 0 deletions PhotoTweaks/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
PhotoTweaksViewController *photoTweaksViewController = [[PhotoTweaksViewController alloc] initWithImage:image];
photoTweaksViewController.delegate = self;
photoTweaksViewController.autoSaveToLibray = YES;
photoTweaksViewController.maxRotationAngle = M_PI_4;
[picker pushViewController:photoTweaksViewController animated:YES];
}

19 changes: 14 additions & 5 deletions PhotoTweaks/PhotoTweaks/PhotoTweakView.h
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@

#import <UIKit/UIKit.h>

extern const CGFloat kMaxRotationAngle;

@class CropView;

@interface PhotoContentView : UIView
@@ -29,15 +31,22 @@

@interface PhotoTweakView : UIView

@property (assign, nonatomic) CGFloat angle;
@property (strong, nonatomic) PhotoContentView *photoContentView;
@property (assign, nonatomic) CGPoint photoContentOffset;
@property (strong, nonatomic) CropView *cropView;
@property (nonatomic, assign, readonly) CGFloat angle;
@property (nonatomic, assign, readonly) CGPoint photoContentOffset;

@property (nonatomic, strong, readonly) CropView *cropView;
@property (nonatomic, strong, readonly) PhotoContentView *photoContentView;
@property (nonatomic, strong, readonly) UISlider *slider;
@property (nonatomic, strong, readonly) UIButton *resetBtn;

- (instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image;

- (instancetype)initWithFrame:(CGRect)frame
image:(UIImage *)image
maxRotationAngle:(CGFloat)maxRotationAngle;

- (instancetype)initWithFrame:(CGRect)frame
image:(UIImage *)image;

- (CGPoint)photoTranslation;

@end
28 changes: 20 additions & 8 deletions PhotoTweaks/PhotoTweaks/PhotoTweakView.m
Original file line number Diff line number Diff line change
@@ -10,8 +10,9 @@
#import "UIColor+Tweak.h"
#import <math.h>

static const int kCropLines = 2;
static const int kGridLines = 9;
const CGFloat kMaxRotationAngle = 0.5;
static const NSUInteger kCropLines = 2;
static const NSUInteger kGridLines = 9;

static const CGFloat kCropViewHotArea = 16;
static const CGFloat kMinimumCropArea = 60;
@@ -55,7 +56,7 @@ - (void)layoutSubviews

@interface PhotoScrollView : UIScrollView

@property (strong, nonatomic) PhotoContentView *photoContentView;
@property (nonatomic, strong) PhotoContentView *photoContentView;

@end

@@ -429,11 +430,13 @@ - (void)showLines:(NSArray *)lines
@interface PhotoTweakView () <UIScrollViewDelegate, CropViewDelegate>

@property (nonatomic, strong) PhotoScrollView *scrollView;
@property (nonatomic, strong) CropView *cropView;

@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) UISlider *slider;
@property (nonatomic, strong) UIButton *resetBtn;
@property (nonatomic, assign) CGSize originalSize;
@property (nonatomic, assign) CGFloat angle;

@property (nonatomic, assign) BOOL manualZoomed;

@@ -447,22 +450,26 @@ @interface PhotoTweakView () <UIScrollViewDelegate, CropViewDelegate>
@property (nonatomic, assign) CGSize maximumCanvasSize;
@property (nonatomic, assign) CGFloat centerY;
@property (nonatomic, assign) CGPoint originalPoint;
@property (nonatomic, assign) CGFloat maxRotationAngle;

@end

@implementation PhotoTweakView

- (instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image
- (instancetype)initWithFrame:(CGRect)frame
image:(UIImage *)image
maxRotationAngle:(CGFloat)maxRotationAngle
{
if (self = [super init]) {

self.frame = frame;

_image = image;
_maxRotationAngle = maxRotationAngle;

// scale the image
_maximumCanvasSize = CGSizeMake(kMaximumCanvasWidthRatio * self.frame.size.width,
kMaximumCanvasHeightRatio * self.frame.size.height - kCanvasHeaderHeigth);
kMaximumCanvasHeightRatio * self.frame.size.height - kCanvasHeaderHeigth);

CGFloat scaleX = image.size.width / self.maximumCanvasSize.width;
CGFloat scaleY = image.size.height / self.maximumCanvasSize.height;
@@ -520,10 +527,10 @@ - (instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image
[self addSubview:_rightMask];
[self updateMasks:NO];

_slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 240, 20)];
_slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 0, 260, 20)];
_slider.center = CGPointMake(CGRectGetWidth(self.bounds) / 2, CGRectGetHeight(self.bounds) - 135);
_slider.minimumValue = -2 * M_PI;
_slider.maximumValue = 2 * M_PI;
_slider.minimumValue = -self.maxRotationAngle;
_slider.maximumValue = self.maxRotationAngle;
[_slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
[_slider addTarget:self action:@selector(sliderTouchEnded:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_slider];
@@ -543,6 +550,11 @@ - (instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image
return self;
}

- (instancetype)initWithFrame:(CGRect)frame image:(UIImage *)image
{
return [self initWithFrame:frame image:image maxRotationAngle:kMaxRotationAngle];
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if (CGRectContainsPoint(self.slider.frame, point)) {
5 changes: 5 additions & 0 deletions PhotoTweaks/PhotoTweaks/PhotoTweaksViewController.h
Original file line number Diff line number Diff line change
@@ -25,6 +25,11 @@
*/
@property (nonatomic, assign) BOOL autoSaveToLibray;

/**
Max rotation angle
*/
@property (nonatomic, assign) CGFloat maxRotationAngle;

/**
The optional photo tweaks controller delegate.
*/
3 changes: 2 additions & 1 deletion PhotoTweaks/PhotoTweaks/PhotoTweaksViewController.m
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ - (instancetype)initWithImage:(UIImage *)image
if (self = [super init]) {
_image = image;
_autoSaveToLibray = YES;
_maxRotationAngle = kMaxRotationAngle;
}
return self;
}
@@ -46,7 +47,7 @@ - (void)viewDidLoad

- (void)setupSubviews
{
self.photoView = [[PhotoTweakView alloc] initWithFrame:self.view.bounds image:self.image];
self.photoView = [[PhotoTweakView alloc] initWithFrame:self.view.bounds image:self.image maxRotationAngle:self.maxRotationAngle];
self.photoView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.photoView];

0 comments on commit 97577e0

Please sign in to comment.