diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index ab8cfe0..3cac5fc 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -14,12 +14,6 @@ A5FE19461E4F553600EA6F73 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19431E4F553600EA6F73 /* AppDelegate.swift */; }; A5FE19471E4F553600EA6F73 /* ExampleCropViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19441E4F553600EA6F73 /* ExampleCropViewController.swift */; }; A5FE19481E4F553600EA6F73 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19451E4F553600EA6F73 /* ViewController.swift */; }; - A5FE19511E4F6ECE00EA6F73 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19501E4F6ECE00EA6F73 /* main.m */; }; - A5FE19541E4F6ECE00EA6F73 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19531E4F6ECE00EA6F73 /* AppDelegate.m */; }; - A5FE19571E4F6ECE00EA6F73 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19561E4F6ECE00EA6F73 /* ViewController.m */; }; - A5FE195A1E4F6ECE00EA6F73 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A5FE19581E4F6ECE00EA6F73 /* Main.storyboard */; }; - A5FE19661E4F726F00EA6F73 /* ExampleCropViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A5FE19651E4F726F00EA6F73 /* ExampleCropViewController.m */; }; - C31BBE2B1F6DF26E57CED1FE /* Pods_ExampleObjC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E001388CF0AFFB056DC06E8 /* Pods_ExampleObjC.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -36,16 +30,6 @@ A5FE19431E4F553600EA6F73 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = SOURCE_ROOT; }; A5FE19441E4F553600EA6F73 /* ExampleCropViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleCropViewController.swift; sourceTree = SOURCE_ROOT; }; A5FE19451E4F553600EA6F73 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = SOURCE_ROOT; }; - A5FE194D1E4F6ECE00EA6F73 /* ExampleObjC.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleObjC.app; sourceTree = BUILT_PRODUCTS_DIR; }; - A5FE19501E4F6ECE00EA6F73 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - A5FE19521E4F6ECE00EA6F73 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - A5FE19531E4F6ECE00EA6F73 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - A5FE19551E4F6ECE00EA6F73 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - A5FE19561E4F6ECE00EA6F73 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; - A5FE19591E4F6ECE00EA6F73 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - A5FE19641E4F726F00EA6F73 /* ExampleCropViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExampleCropViewController.h; sourceTree = ""; }; - A5FE19651E4F726F00EA6F73 /* ExampleCropViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExampleCropViewController.m; sourceTree = ""; }; - A5FE196E1E4F870900EA6F73 /* IGRPhotoTweaks-Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IGRPhotoTweaks-Swift.h"; sourceTree = ""; }; B5E4CDA77E8F904599EAFE3C /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -58,14 +42,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - A5FE194A1E4F6ECE00EA6F73 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C31BBE2B1F6DF26E57CED1FE /* Pods_ExampleObjC.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -82,7 +58,6 @@ isa = PBXGroup; children = ( A5DFB1C71E481FE4009ACD31 /* Example */, - A5FE194E1E4F6ECE00EA6F73 /* ExampleObjC */, A5DFB1CB1E481FE4009ACD31 /* Resources */, A5DFB1D11E481FE4009ACD31 /* Settings */, A5DFB1B31E481F48009ACD31 /* Products */, @@ -95,7 +70,6 @@ isa = PBXGroup; children = ( A5DFB1B21E481F48009ACD31 /* Example.app */, - A5FE194D1E4F6ECE00EA6F73 /* ExampleObjC.app */, ); name = Products; sourceTree = ""; @@ -128,30 +102,6 @@ path = Settings; sourceTree = ""; }; - A5FE194E1E4F6ECE00EA6F73 /* ExampleObjC */ = { - isa = PBXGroup; - children = ( - A5FE19521E4F6ECE00EA6F73 /* AppDelegate.h */, - A5FE19531E4F6ECE00EA6F73 /* AppDelegate.m */, - A5FE19551E4F6ECE00EA6F73 /* ViewController.h */, - A5FE19561E4F6ECE00EA6F73 /* ViewController.m */, - A5FE19641E4F726F00EA6F73 /* ExampleCropViewController.h */, - A5FE19651E4F726F00EA6F73 /* ExampleCropViewController.m */, - A5FE19581E4F6ECE00EA6F73 /* Main.storyboard */, - A5FE194F1E4F6ECE00EA6F73 /* Supporting Files */, - A5FE196E1E4F870900EA6F73 /* IGRPhotoTweaks-Swift.h */, - ); - path = ExampleObjC; - sourceTree = ""; - }; - A5FE194F1E4F6ECE00EA6F73 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - A5FE19501E4F6ECE00EA6F73 /* main.m */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; D0C927687C190AB5C9A48AE6 /* Pods */ = { isa = PBXGroup; children = ( @@ -186,25 +136,6 @@ productReference = A5DFB1B21E481F48009ACD31 /* Example.app */; productType = "com.apple.product-type.application"; }; - A5FE194C1E4F6ECE00EA6F73 /* ExampleObjC */ = { - isa = PBXNativeTarget; - buildConfigurationList = A5FE19631E4F6ECE00EA6F73 /* Build configuration list for PBXNativeTarget "ExampleObjC" */; - buildPhases = ( - FAF484DFF2853C7C099CC5DF /* [CP] Check Pods Manifest.lock */, - A5FE19491E4F6ECE00EA6F73 /* Sources */, - A5FE194A1E4F6ECE00EA6F73 /* Frameworks */, - A5FE194B1E4F6ECE00EA6F73 /* Resources */, - BED4765AF2FDF8358050E039 /* [CP] Embed Pods Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = ExampleObjC; - productName = ExampleObjC; - productReference = A5FE194D1E4F6ECE00EA6F73 /* ExampleObjC.app */; - productType = "com.apple.product-type.application"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -222,12 +153,6 @@ LastSwiftMigration = 0900; ProvisioningStyle = Automatic; }; - A5FE194C1E4F6ECE00EA6F73 = { - CreatedOnToolsVersion = 8.2.1; - DevelopmentTeam = DMP42GVPJ3; - LastSwiftMigration = 0820; - ProvisioningStyle = Automatic; - }; }; }; buildConfigurationList = A5DFB1AD1E481F48009ACD31 /* Build configuration list for PBXProject "Example" */; @@ -244,7 +169,6 @@ projectRoot = ""; targets = ( A5DFB1B11E481F48009ACD31 /* Example */, - A5FE194C1E4F6ECE00EA6F73 /* ExampleObjC */, ); }; /* End PBXProject section */ @@ -260,14 +184,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - A5FE194B1E4F6ECE00EA6F73 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A5FE195A1E4F6ECE00EA6F73 /* Main.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -302,26 +218,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - BED4765AF2FDF8358050E039 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${SRCROOT}/Pods/Target Support Files/Pods-ExampleObjC/Pods-ExampleObjC-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/HorizontalDial/HorizontalDial.framework", - "${BUILT_PRODUCTS_DIR}/IGRPhotoTweaks/IGRPhotoTweaks.framework", - ); - name = "[CP] Embed Pods Frameworks"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HorizontalDial.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/IGRPhotoTweaks.framework", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ExampleObjC/Pods-ExampleObjC-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; DD24609E454B4037F6F9D18F /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -342,24 +238,6 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - FAF484DFF2853C7C099CC5DF /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-ExampleObjC-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -373,17 +251,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - A5FE19491E4F6ECE00EA6F73 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - A5FE19571E4F6ECE00EA6F73 /* ViewController.m in Sources */, - A5FE19661E4F726F00EA6F73 /* ExampleCropViewController.m in Sources */, - A5FE19541E4F6ECE00EA6F73 /* AppDelegate.m in Sources */, - A5FE19511E4F6ECE00EA6F73 /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ @@ -403,14 +270,6 @@ name = Main.storyboard; sourceTree = ""; }; - A5FE19581E4F6ECE00EA6F73 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - A5FE19591E4F6ECE00EA6F73 /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -541,30 +400,6 @@ }; name = Release; }; - A5FE19611E4F6ECE00EA6F73 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 3D9A19D6F45607DA91F31157 /* Pods-ExampleObjC.debug.xcconfig */; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - DEVELOPMENT_TEAM = DMP42GVPJ3; - INFOPLIST_FILE = "$(SRCROOT)/Settings/Info.plist"; - PRODUCT_BUNDLE_IDENTIFIER = com.igrsoft.ExampleObjC; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - A5FE19621E4F6ECE00EA6F73 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 91908735A031EC6576B9A740 /* Pods-ExampleObjC.release.xcconfig */; - buildSettings = { - CLANG_ENABLE_MODULES = YES; - DEVELOPMENT_TEAM = DMP42GVPJ3; - INFOPLIST_FILE = "$(SRCROOT)/Settings/Info.plist"; - PRODUCT_BUNDLE_IDENTIFIER = com.igrsoft.ExampleObjC; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -586,15 +421,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - A5FE19631E4F6ECE00EA6F73 /* Build configuration list for PBXNativeTarget "ExampleObjC" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - A5FE19611E4F6ECE00EA6F73 /* Debug */, - A5FE19621E4F6ECE00EA6F73 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = A5DFB1AA1E481F48009ACD31 /* Project object */; diff --git a/Example/ExampleCropViewController.swift b/Example/ExampleCropViewController.swift index 9a9b150..c5897cf 100644 --- a/Example/ExampleCropViewController.swift +++ b/Example/ExampleCropViewController.swift @@ -79,8 +79,7 @@ class ExampleCropViewController: IGRPhotoTweakViewController { @IBAction func onChandeAngleSliderValue(_ sender: UISlider) { let radians: CGFloat = CGFloat(sender.value) setupAngleLabelValue(radians: radians) - self.changedAngle(value: radians) - + self.changeAngle(radians: radians) } @IBAction func onEndTouchAngleControl(_ sender: UIControl) { @@ -190,7 +189,7 @@ extension ExampleCropViewController: HorizontalDialDelegate { let radians = IGRRadianAngle.toRadians(CGFloat(degrees)) self.setupAngleLabelValue(radians: radians) - self.changedAngle(value: radians) + self.changeAngle(radians: radians) } func horizontalDialDidEndScroll(_ horizontalDial: HorizontalDial) { diff --git a/Example/ExampleObjC/ExampleCropViewController.m b/Example/ExampleObjC/ExampleCropViewController.m index 6db5eb8..8789496 100644 --- a/Example/ExampleObjC/ExampleCropViewController.m +++ b/Example/ExampleObjC/ExampleCropViewController.m @@ -63,7 +63,7 @@ - (void)setupAngleLabelValue:(CGFloat)radians { - (IBAction)onChandeAngleSliderValue:(UISlider *)sender { CGFloat radians = sender.value; [self setupAngleLabelValue:radians]; - [self changedAngleWithValue:radians]; + [self changeAngleWithValue:radians]; } - (IBAction)onEndTouchAngleControl:(UIControl *)sender { @@ -73,7 +73,7 @@ - (IBAction)onEndTouchAngleControl:(UIControl *)sender { - (IBAction)onChandeAnglePickerViewValue:(UIPickerView *)sender { CGFloat radians = CGFloat.zero; [self setupAngleLabelValue:radians]; - [self changedAngleWithValue:radians]; + [self changeAngleWithValue:radians]; } - (IBAction)onTouchResetButton:(UIButton *)sender { diff --git a/IGRPhotoTweaks/Category/CGImage+IGRPhotoTweakExtension.swift b/IGRPhotoTweaks/Category/CGImage+IGRPhotoTweakExtension.swift index 7024233..b8ef5cf 100644 --- a/IGRPhotoTweaks/Category/CGImage+IGRPhotoTweakExtension.swift +++ b/IGRPhotoTweaks/Category/CGImage+IGRPhotoTweakExtension.swift @@ -38,9 +38,9 @@ extension CGImage { context?.concatenate(transform) context?.scaleBy(x: 1.0, y: -1.0) context?.draw(self, in: CGRect(x: (-imageViewSize.width.half), - y: (-imageViewSize.height.half), - width: imageViewSize.width, - height: imageViewSize.height)) + y: (-imageViewSize.height.half), + width: imageViewSize.width, + height: imageViewSize.height)) let result = context!.makeImage()! diff --git a/IGRPhotoTweaks/IGRPhotoTweakViewController+Angle.swift b/IGRPhotoTweaks/IGRPhotoTweakViewController+Angle.swift index 7315964..ce6c446 100644 --- a/IGRPhotoTweaks/IGRPhotoTweakViewController+Angle.swift +++ b/IGRPhotoTweaks/IGRPhotoTweakViewController+Angle.swift @@ -9,8 +9,8 @@ import Foundation extension IGRPhotoTweakViewController { - public func changedAngle(value: CGFloat) { - self.photoView.changedAngle(value: value) + public func changeAngle(radians: CGFloat) { + self.photoView.changeAngle(radians: radians) } public func stopChangeAngle() { diff --git a/IGRPhotoTweaks/IGRPhotoTweakViewController+PHPhotoLibrary.swift b/IGRPhotoTweaks/IGRPhotoTweakViewController+PHPhotoLibrary.swift index d86b7f9..c637283 100644 --- a/IGRPhotoTweaks/IGRPhotoTweakViewController+PHPhotoLibrary.swift +++ b/IGRPhotoTweaks/IGRPhotoTweakViewController+PHPhotoLibrary.swift @@ -10,7 +10,7 @@ import Foundation import Photos extension IGRPhotoTweakViewController { - + internal func saveToLibrary(image: UIImage) { let writePhotoToLibraryBlock: (() -> Void)? = { UIImageWriteToSavedPhotosAlbum(image, self, #selector(self.image(image:didFinishSavingWithError:contextInfo:)), nil) diff --git a/IGRPhotoTweaks/IGRPhotoTweakViewController.swift b/IGRPhotoTweaks/IGRPhotoTweakViewController.swift index 61ed232..5e4db76 100644 --- a/IGRPhotoTweaks/IGRPhotoTweakViewController.swift +++ b/IGRPhotoTweaks/IGRPhotoTweakViewController.swift @@ -113,7 +113,7 @@ open class IGRPhotoTweakViewController: UIViewController { let translation: CGPoint = self.photoView.photoTranslation transform = transform.translatedBy(x: translation.x, y: translation.y) // rotate - transform = transform.rotated(by: self.photoView.angle) + transform = transform.rotated(by: self.photoView.radians) // scale let t: CGAffineTransform = self.photoView.photoContentView.transform diff --git a/IGRPhotoTweaks/PhotoTweakView/CropView/IGRCropView+UITouch.swift b/IGRPhotoTweaks/PhotoTweakView/CropView/IGRCropView+UITouch.swift index b671cc9..32d7a92 100644 --- a/IGRPhotoTweaks/PhotoTweakView/CropView/IGRCropView+UITouch.swift +++ b/IGRPhotoTweaks/PhotoTweakView/CropView/IGRCropView+UITouch.swift @@ -70,7 +70,7 @@ extension IGRCropView { width: frame.size.width, height: newHeight) } - + //TODO: Added test cropViewInsideValidFrame if (frame.size.width > self.cornerBorderLength diff --git a/IGRPhotoTweaks/PhotoTweakView/CropView/IGRCropView.swift b/IGRPhotoTweaks/PhotoTweakView/CropView/IGRCropView.swift index b413685..1691646 100644 --- a/IGRPhotoTweaks/PhotoTweakView/CropView/IGRCropView.swift +++ b/IGRPhotoTweaks/PhotoTweakView/CropView/IGRCropView.swift @@ -46,24 +46,24 @@ public class IGRCropView: UIView { var lines = self.setupHorisontalLines(count: kCropLines, className: IGRCropLine.self) return lines as! [IGRCropLine] - }(()) + }(()) internal lazy var verticalCropLines: [IGRCropLine] = { [unowned self] by in var lines = self.setupVerticalLines(count: kCropLines, className: IGRCropLine.self) return lines as! [IGRCropLine] - }(()) + }(()) internal lazy var horizontalGridLines: [IGRCropGridLine] = { [unowned self] by in var lines = self.setupHorisontalLines(count: kGridLines, className: IGRCropGridLine.self) return lines as! [IGRCropGridLine] - }(()) + }(()) internal lazy var verticalGridLines: [IGRCropGridLine] = { [unowned self] by in var lines = self.setupVerticalLines(count: kGridLines, className: IGRCropGridLine.self) return lines as! [IGRCropGridLine] - }(()) + }(()) internal var cornerBorderLength = kCropViewCornerLength internal var cornerBorderWidth = kCropViewCornerWidth diff --git a/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+Angle.swift b/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+Angle.swift index c65ff0f..f1288a7 100644 --- a/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+Angle.swift +++ b/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+Angle.swift @@ -9,7 +9,7 @@ import Foundation extension IGRPhotoTweakView { - public func changedAngle(value: CGFloat) { + public func changeAngle(radians: CGFloat) { // update masks self.highlightMask(true, animate: false) @@ -17,8 +17,8 @@ extension IGRPhotoTweakView { self.cropView.updateGridLines(animate: false) // rotate scroll view - self.angle = value - self.scrollView.transform = CGAffineTransform(rotationAngle: self.angle) + self.radians = radians + self.scrollView.transform = CGAffineTransform(rotationAngle: self.radians) self.updatePosition() } diff --git a/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+IGRCropView.swift b/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+IGRCropView.swift index 15b0272..601d3e4 100644 --- a/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+IGRCropView.swift +++ b/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+IGRCropView.swift @@ -39,8 +39,8 @@ extension IGRPhotoTweakView : IGRCropViewDelegate { height: (scale * cropView.frame.size.height)) // calculate the new bounds of scroll view - let width: CGFloat = abs(cos(self.angle)) * newCropBounds.size.width + abs(sin(self.angle)) * newCropBounds.size.height - let height: CGFloat = abs(sin(self.angle)) * newCropBounds.size.width + abs(cos(self.angle)) * newCropBounds.size.height + let width: CGFloat = abs(cos(self.radians)) * newCropBounds.size.width + abs(sin(self.radians)) * newCropBounds.size.height + let height: CGFloat = abs(sin(self.radians)) * newCropBounds.size.width + abs(cos(self.radians)) * newCropBounds.size.height // calculate the zoom area of scroll view var scaleFrame: CGRect = cropView.frame diff --git a/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+Mask.swift b/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+Mask.swift index 85db1ed..e3ec919 100644 --- a/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+Mask.swift +++ b/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView+Mask.swift @@ -9,7 +9,7 @@ import Foundation extension IGRPhotoTweakView { - + internal func setupMasks() { self.topMask = IGRCropMaskView() diff --git a/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView.swift b/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView.swift index 645c03d..872580e 100644 --- a/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView.swift +++ b/IGRPhotoTweaks/PhotoTweakView/IGRPhotoTweakView.swift @@ -17,8 +17,8 @@ public class IGRPhotoTweakView: UIView { private(set) lazy var cropView: IGRCropView! = { [unowned self] by in let cropView = IGRCropView(frame: self.scrollView.frame, - cornerBorderWidth:self.cornerBorderWidth(), - cornerBorderLength:self.cornerBorderLength()) + cornerBorderWidth:self.cornerBorderWidth(), + cornerBorderLength:self.cornerBorderLength()) cropView.center = self.scrollView.center cropView.layer.borderColor = self.borderColor().cgColor @@ -26,7 +26,7 @@ public class IGRPhotoTweakView: UIView { self.addSubview(cropView) return cropView - }(()) + }(()) public private(set) lazy var photoContentView: IGRPhotoContentView! = { [unowned self] by in @@ -35,7 +35,7 @@ public class IGRPhotoTweakView: UIView { self.scrollView.addSubview(photoContentView) return photoContentView - }(()) + }(()) public var photoTranslation: CGPoint { get { @@ -51,7 +51,7 @@ public class IGRPhotoTweakView: UIView { //MARK: - Private VARs - internal var angle: CGFloat = CGFloat.zero + internal var radians: CGFloat = CGFloat.zero fileprivate var photoContentOffset = CGPoint.zero internal lazy var scrollView: IGRPhotoScrollView! = { [unowned self] by in @@ -66,7 +66,7 @@ public class IGRPhotoTweakView: UIView { self.addSubview(scrollView) return scrollView - }(()) + }(()) internal weak var image: UIImage! internal var originalSize = CGSize.zero @@ -112,10 +112,10 @@ public class IGRPhotoTweakView: UIView { } //MARK: - Public FUNCs - + public func resetView() { UIView.animate(withDuration: kAnimationDuration, animations: {() -> Void in - self.angle = 0 + self.radians = CGFloat.zero self.scrollView.transform = CGAffineTransform.identity self.scrollView.center = CGPoint(x: self.frame.width.half, y: self.centerY) self.scrollView.bounds = CGRect(x: CGFloat.zero, @@ -166,8 +166,8 @@ public class IGRPhotoTweakView: UIView { internal func updatePosition() { // position scroll view - let width: CGFloat = abs(cos(self.angle)) * self.cropView.frame.size.width + abs(sin(self.angle)) * self.cropView.frame.size.height - let height: CGFloat = abs(sin(self.angle)) * self.cropView.frame.size.width + abs(cos(self.angle)) * self.cropView.frame.size.height + let width: CGFloat = abs(cos(self.radians)) * self.cropView.frame.size.width + abs(sin(self.radians)) * self.cropView.frame.size.height + let height: CGFloat = abs(sin(self.radians)) * self.cropView.frame.size.width + abs(cos(self.radians)) * self.cropView.frame.size.height let center: CGPoint = self.scrollView.center let contentOffset: CGPoint = self.scrollView.contentOffset let contentOffsetCenter = CGPoint(x: (contentOffset.x + self.scrollView.bounds.size.width.half), diff --git a/README.md b/README.md index e47745e..a4ad414 100755 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ fileprivate func setupSlider() { @IBAction func onChandeAngleSliderValue(_ sender: UISlider) { let radians: CGFloat = CGFloat(sender.value) - self.changedAngle(value: radians) + self.changeAngle(radians: radians) } ```