Skip to content

Commit

Permalink
Merge pull request #80 from ruslanskorb/develop
Browse files Browse the repository at this point in the history
Version 1.4.1
  • Loading branch information
ruslanskorb committed Nov 13, 2015
2 parents 3a56f73 + 093cc30 commit eaa3b67
Show file tree
Hide file tree
Showing 20 changed files with 89 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.0</string>
<string>1.4.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,25 +544,36 @@ - (void)resetZoomScale;
sharedIt();
};

it(@"looks right when crop mode is `RSKImageCropModeCircle`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];
describe(@"crop mode", ^{
it(@"looks right when crop mode is `RSKImageCropModeCircle`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];

sharedPortraitIt();
});

sharedPortraitIt();
});

it(@"looks right when crop mode is `RSKImageCropModeSquare`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];
it(@"looks right when crop mode is `RSKImageCropModeSquare`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];
sharedPortraitIt();
});

sharedPortraitIt();
it(@"looks right when crop mode is `RSKImageCropModeCustom`", ^{
RSKImageCropViewControllerDataSourceObject1 *dataSourceObject = [[RSKImageCropViewControllerDataSourceObject1 alloc] init];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCustom];
imageCropViewController.dataSource = dataSourceObject;

sharedPortraitIt();
});
});

it(@"looks right when crop mode is `RSKImageCropModeCustom`", ^{
RSKImageCropViewControllerDataSourceObject1 *dataSourceObject = [[RSKImageCropViewControllerDataSourceObject1 alloc] init];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCustom];
imageCropViewController.dataSource = dataSourceObject;

sharedPortraitIt();
describe(@"stroke of the mask", ^{
it(@"looks right when stroked outline is visible", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];
imageCropViewController.maskLayerStrokeColor = [UIColor whiteColor];
sharedPortraitIt();
});
});
});

Expand All @@ -573,25 +584,36 @@ - (void)resetZoomScale;
sharedIt();
};

it(@"looks right when crop mode is `RSKImageCropModeCircle`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];
describe(@"crop mode", ^{
it(@"looks right when crop mode is `RSKImageCropModeCircle`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCircle];

sharedLandscapeIt();
});

sharedLandscapeIt();
});

it(@"looks right when crop mode is `RSKImageCropModeSquare`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];
it(@"looks right when crop mode is `RSKImageCropModeSquare`", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];
sharedLandscapeIt();
});

sharedLandscapeIt();
it(@"looks right when crop mode is `RSKImageCropModeCustom`", ^{
RSKImageCropViewControllerDataSourceObject1 *dataSourceObject = [[RSKImageCropViewControllerDataSourceObject1 alloc] init];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCustom];
imageCropViewController.dataSource = dataSourceObject;

sharedLandscapeIt();
});
});

it(@"looks right when crop mode is `RSKImageCropModeCustom`", ^{
RSKImageCropViewControllerDataSourceObject1 *dataSourceObject = [[RSKImageCropViewControllerDataSourceObject1 alloc] init];

imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeCustom];
imageCropViewController.dataSource = dataSourceObject;

sharedLandscapeIt();
describe(@"stroke of the mask", ^{
it(@"looks right when storked outline is visible", ^{
imageCropViewController = [[RSKImageCropViewController alloc] initWithImage:originalImage cropMode:RSKImageCropModeSquare];
imageCropViewController.maskLayerStrokeColor = [UIColor whiteColor];
sharedLandscapeIt();
});
});
});
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.4.0</string>
<string>1.4.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion RSKImageCropper.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RSKImageCropper'
s.version = '1.4.0'
s.version = '1.4.1'
s.summary = 'An image cropper for iOS like in the Contacts app with support for landscape orientation.'
s.homepage = 'https://github.com/ruslanskorb/RSKImageCropper'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
12 changes: 6 additions & 6 deletions RSKImageCropper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.4.0;
CURRENT_PROJECT_VERSION = 1.4.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -274,7 +274,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.4.0;
CURRENT_PROJECT_VERSION = 1.4.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -300,8 +300,8 @@
isa = XCBuildConfiguration;
buildSettings = {
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1.4.0;
DYLIB_CURRENT_VERSION = 1.4.0;
DYLIB_COMPATIBILITY_VERSION = 1.4.1;
DYLIB_CURRENT_VERSION = 1.4.1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand All @@ -316,8 +316,8 @@
isa = XCBuildConfiguration;
buildSettings = {
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1.4.0;
DYLIB_CURRENT_VERSION = 1.4.0;
DYLIB_COMPATIBILITY_VERSION = 1.4.1;
DYLIB_CURRENT_VERSION = 1.4.1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down
31 changes: 28 additions & 3 deletions RSKImageCropper/RSKImageCropViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ @interface RSKImageCropViewController () <UIGestureRecognizerDelegate>
@property (strong, nonatomic) RSKImageScrollView *imageScrollView;
@property (strong, nonatomic) RSKTouchView *overlayView;
@property (strong, nonatomic) CAShapeLayer *maskLayer;

@property (assign, nonatomic) CGRect maskRect;
@property (copy, nonatomic) UIBezierPath *maskPath;

@property (readonly, nonatomic) CGRect rectForMaskPath;
@property (readonly, nonatomic) CGRect rectForClipPath;

@property (strong, nonatomic) UILabel *moveAndScaleLabel;
@property (strong, nonatomic) UIButton *cancelButton;
@property (strong, nonatomic) UIButton *chooseButton;
Expand Down Expand Up @@ -393,6 +398,26 @@ - (CGRect)cropRect
return cropRect;
}

- (CGRect)rectForClipPath
{
if (!self.maskLayerStrokeColor) {
return self.overlayView.frame;
} else {
CGFloat maskLayerLineHalfWidth = self.maskLayerLineWidth / 2.0;
return CGRectInset(self.overlayView.frame, -maskLayerLineHalfWidth, -maskLayerLineHalfWidth);
}
}

- (CGRect)rectForMaskPath
{
if (!self.maskLayerStrokeColor) {
return self.maskRect;
} else {
CGFloat maskLayerLineHalfWidth = self.maskLayerLineWidth / 2.0;
return CGRectInset(self.maskRect, maskLayerLineHalfWidth, maskLayerLineHalfWidth);
}
}

- (CGFloat)rotationAngle
{
CGAffineTransform transform = self.imageScrollView.transform;
Expand Down Expand Up @@ -440,7 +465,7 @@ - (void)setMaskPath:(UIBezierPath *)maskPath
if (![_maskPath isEqual:maskPath]) {
_maskPath = maskPath;

UIBezierPath *clipPath = [UIBezierPath bezierPathWithRect:self.overlayView.frame];
UIBezierPath *clipPath = [UIBezierPath bezierPathWithRect:self.rectForClipPath];
[clipPath appendPath:maskPath];
clipPath.usesEvenOddFillRule = YES;

Expand Down Expand Up @@ -760,11 +785,11 @@ - (void)updateMaskPath
{
switch (self.cropMode) {
case RSKImageCropModeCircle: {
self.maskPath = [UIBezierPath bezierPathWithOvalInRect:self.maskRect];
self.maskPath = [UIBezierPath bezierPathWithOvalInRect:self.rectForMaskPath];
break;
}
case RSKImageCropModeSquare: {
self.maskPath = [UIBezierPath bezierPathWithRect:self.maskRect];
self.maskPath = [UIBezierPath bezierPathWithRect:self.rectForMaskPath];
break;
}
case RSKImageCropModeCustom: {
Expand Down

0 comments on commit eaa3b67

Please sign in to comment.