diff --git a/Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist b/Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist index de52830..bfb557b 100755 --- a/Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist +++ b/Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.4.0 + 1.4.1 CFBundleSignature ???? CFBundleVersion diff --git a/Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m b/Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m index cf1faa4..8820074 100644 --- a/Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m +++ b/Example/RSKImageCropperExampleTests/RSKImageCropViewControllerTests.m @@ -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(); + }); }); }); @@ -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(); + }); }); }); }); diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCircle@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCircle@2x.png new file mode 100644 index 0000000..6b0fd81 Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCircle@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCustom@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCustom@2x.png new file mode 100644 index 0000000..0af60dc Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCustom@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeSquare@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeSquare@2x.png new file mode 100644 index 0000000..ab5c9a8 Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeSquare@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroke_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroke_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png new file mode 100644 index 0000000..14992eb Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroke_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_looks_right_when_storked_outline_is_visible@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_looks_right_when_storked_outline_is_visible@2x.png new file mode 100644 index 0000000..14992eb Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_looks_right_when_storked_outline_is_visible@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_looks_right_when_stroked_color_is_not_equal_to_nil@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_looks_right_when_stroked_color_is_not_equal_to_nil@2x.png new file mode 100644 index 0000000..14992eb Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_looks_right_when_stroked_color_is_not_equal_to_nil@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png new file mode 100644 index 0000000..14992eb Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_landscape_stroked_outline_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCircle@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCircle@2x.png new file mode 100644 index 0000000..c689dfc Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCircle@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCustom@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCustom@2x.png new file mode 100644 index 0000000..8a5dcf6 Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeCustom@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeSquare@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeSquare@2x.png new file mode 100644 index 0000000..dd6b2b8 Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_crop_mode_looks_right_when_crop_mode_is_RSKImageCropModeSquare@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroke_of_the_mask_looks_right_when_stroked_outline_is_visible@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroke_of_the_mask_looks_right_when_stroked_outline_is_visible@2x.png new file mode 100644 index 0000000..334a62b Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroke_of_the_mask_looks_right_when_stroked_outline_is_visible@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_looks_right_when_storked_outline_is_visible@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_looks_right_when_storked_outline_is_visible@2x.png new file mode 100644 index 0000000..334a62b Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_looks_right_when_storked_outline_is_visible@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_looks_right_when_stroked_color_is_not_equal_to_nil@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_looks_right_when_stroked_color_is_not_equal_to_nil@2x.png new file mode 100644 index 0000000..334a62b Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_looks_right_when_stroked_color_is_not_equal_to_nil@2x.png differ diff --git a/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png new file mode 100644 index 0000000..334a62b Binary files /dev/null and b/Example/RSKImageCropperExampleTests/ReferenceImages/RSKImageCropViewControllerSpec/crop_view_portrait_stroked_outline_of_the_mask_looks_right_when_storked_outline_is_visible@2x.png differ diff --git a/Framework/Info.plist b/Framework/Info.plist index 8bce5c7..07b3f7e 100755 --- a/Framework/Info.plist +++ b/Framework/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.4.0 + 1.4.1 CFBundleSignature ???? CFBundleVersion diff --git a/RSKImageCropper.podspec b/RSKImageCropper.podspec index cba9fed..3c6120d 100644 --- a/RSKImageCropper.podspec +++ b/RSKImageCropper.podspec @@ -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' } diff --git a/RSKImageCropper.xcodeproj/project.pbxproj b/RSKImageCropper.xcodeproj/project.pbxproj index 05fc662..1868a6e 100755 --- a/RSKImageCropper.xcodeproj/project.pbxproj +++ b/RSKImageCropper.xcodeproj/project.pbxproj @@ -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; @@ -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; @@ -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"; @@ -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"; diff --git a/RSKImageCropper/RSKImageCropViewController.m b/RSKImageCropper/RSKImageCropViewController.m index d907f1a..9ce88c4 100644 --- a/RSKImageCropper/RSKImageCropViewController.m +++ b/RSKImageCropper/RSKImageCropViewController.m @@ -61,8 +61,13 @@ @interface RSKImageCropViewController () @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; @@ -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; @@ -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; @@ -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: {