diff --git a/ALCameraViewController.podspec b/ALCameraViewController.podspec index 58fe93d3..d7dd9899 100644 --- a/ALCameraViewController.podspec +++ b/ALCameraViewController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "ALCameraViewController" - spec.version = "3.0.2" + spec.version = "3.0.3" spec.summary = "A camera view controller with custom image picker and image cropping." spec.source = { :git => "https://github.com/AlexLittlejohn/ALCameraViewController.git", :tag => spec.version.to_s } spec.requires_arc = true diff --git a/ALCameraViewController.xcodeproj/project.pbxproj b/ALCameraViewController.xcodeproj/project.pbxproj index 1b01a1a3..720f06f0 100644 --- a/ALCameraViewController.xcodeproj/project.pbxproj +++ b/ALCameraViewController.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 1F3C56291F701CA7009667E9 /* CroppingParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */; }; 7AC96FA21F5B5166003E53F4 /* CroppingParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */; }; + 7C6AF41F1FB340CA006CB4ED /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7C6AF41E1FB340CA006CB4ED /* LaunchScreen.xib */; }; C40665441C73A47C00EB9751 /* SingleImageSaver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665431C73A47C00EB9751 /* SingleImageSaver.swift */; }; C40665461C73A94100EB9751 /* CameraGlobals.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665451C73A94100EB9751 /* CameraGlobals.swift */; }; C40665481C73B72D00EB9751 /* SingleImageFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = C40665471C73B72D00EB9751 /* SingleImageFetcher.swift */; }; @@ -61,6 +62,7 @@ /* Begin PBXFileReference section */ 7AC96FA11F5B5166003E53F4 /* CroppingParameters.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CroppingParameters.swift; sourceTree = ""; }; + 7C6AF41E1FB340CA006CB4ED /* LaunchScreen.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = ""; }; C40665431C73A47C00EB9751 /* SingleImageSaver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageSaver.swift; sourceTree = ""; }; C40665451C73A94100EB9751 /* CameraGlobals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CameraGlobals.swift; sourceTree = ""; }; C40665471C73B72D00EB9751 /* SingleImageFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleImageFetcher.swift; sourceTree = ""; }; @@ -196,6 +198,7 @@ FAF058421B31618D008E5592 /* Supporting Files */ = { isa = PBXGroup; children = ( + 7C6AF41E1FB340CA006CB4ED /* LaunchScreen.xib */, FAF0584B1B31618D008E5592 /* Images.xcassets */, FAF058431B31618D008E5592 /* Info.plist */, ); @@ -322,6 +325,7 @@ files = ( FA52EE0B1B44129B00E16B6F /* ViewController.xib in Resources */, FA8231381B3BF8F700A837BE /* CameraView.strings in Resources */, + 7C6AF41F1FB340CA006CB4ED /* LaunchScreen.xib in Resources */, FA5FA3451B3AFEB300497C62 /* CameraViewAssets.xcassets in Resources */, FAF0584C1B31618D008E5592 /* Images.xcassets in Resources */, FA778A411B8319D8005807E7 /* image.jpg in Resources */, @@ -543,11 +547,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = 2466624KEK; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -560,11 +563,10 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = 2466624KEK; INFOPLIST_FILE = "Example/Supporting Files/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.alx.zero.CameraViewController; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift index 4b485532..37e518c9 100644 --- a/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift +++ b/ALCameraViewController/ViewController/CameraViewControllerConstraint.swift @@ -46,10 +46,10 @@ extension CameraViewController { let attribute : NSLayoutAttribute = { switch statusBarOrientation { - case .portrait: return .bottom - case .landscapeRight: return .right - case .landscapeLeft: return .left - default: return .top + case .portrait: return .bottomMargin + case .landscapeRight: return .rightMargin + case .landscapeLeft: return .leftMargin + default: return .topMargin } }() @@ -60,7 +60,7 @@ extension CameraViewController { toItem: view, attribute: attribute, multiplier: 1.0, - constant: attribute == .right || attribute == .bottom ? -8 : 8) + constant: -8) view.addConstraint(cameraButtonEdgeConstraint!) } @@ -401,7 +401,7 @@ extension CameraViewController { view.autoRemoveConstraint(flashButtonEdgeConstraint) let constraintRight = statusBarOrientation == .portrait || statusBarOrientation == .landscapeRight - let attribute : NSLayoutAttribute = constraintRight ? .top : .bottom + let attribute : NSLayoutAttribute = constraintRight ? .topMargin : .bottomMargin flashButtonEdgeConstraint = NSLayoutConstraint( item: flashButton, diff --git a/ALCameraViewController/ViewController/ConfirmViewController.swift b/ALCameraViewController/ViewController/ConfirmViewController.swift index d9eccd23..5c7fb257 100644 --- a/ALCameraViewController/ViewController/ConfirmViewController.swift +++ b/ALCameraViewController/ViewController/ConfirmViewController.swift @@ -106,7 +106,6 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { scrollView.minimumZoomScale = scale scrollView.zoomScale = scale centerScrollViewContents() - centerImageViewOnRotate() } public override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { @@ -163,21 +162,13 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { } guard let image = imageView.image else { - return 1 + return 1 } let scaleWidth = _size.width / image.size.width let scaleHeight = _size.height / image.size.height - - var scale: CGFloat - - if croppingParameters.isEnabled { - scale = max(scaleWidth, scaleHeight) - } else { - scale = min(scaleWidth, scaleHeight) - } - - return scale + + return min(scaleWidth, scaleHeight) } private func calculateScrollViewInsets(_ frame: CGRect) -> UIEdgeInsets { @@ -318,14 +309,17 @@ public class ConfirmViewController: UIViewController, UIScrollViewDelegate { y: cropOverlay.frame.origin.y + cropOverlay.outterGap, width: cropOverlay.frame.size.width - 2 * cropOverlay.outterGap, height: cropOverlay.frame.size.height - 2 * cropOverlay.outterGap) - cropRect.origin.x += scrollView.contentOffset.x - cropRect.origin.y += scrollView.contentOffset.y - - let normalizedX = cropRect.origin.x / imageView.frame.width - let normalizedY = cropRect.origin.y / imageView.frame.height - - let normalizedWidth = cropRect.width / imageView.frame.width - let normalizedHeight = cropRect.height / imageView.frame.height + cropRect.origin.x += scrollView.contentOffset.x - imageView.frame.origin.x + cropRect.origin.y += scrollView.contentOffset.y - imageView.frame.origin.y + + let normalizedX = max(0, cropRect.origin.x / imageView.frame.width) + let normalizedY = max(0, cropRect.origin.y / imageView.frame.height) + + let extraWidth = min(0, cropRect.origin.x) + let extraHeight = min(0, cropRect.origin.y) + + let normalizedWidth = min(1, (cropRect.width + extraWidth) / imageView.frame.width) + let normalizedHeight = min(1, (cropRect.height + extraHeight) / imageView.frame.height) return CGRect(x: normalizedX, y: normalizedY, width: normalizedWidth, height: normalizedHeight) } diff --git a/Example/Supporting Files/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/Supporting Files/Images.xcassets/AppIcon.appiconset/Contents.json index 4be0545c..0e887cfc 100644 --- a/Example/Supporting Files/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/Supporting Files/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "size" : "29x29", "idiom" : "iphone", @@ -25,8 +35,8 @@ "scale" : "3x" }, { - "idiom" : "iphone", "size" : "60x60", + "idiom" : "iphone", "filename" : "icon@120.png", "scale" : "2x" }, @@ -35,10 +45,15 @@ "idiom" : "iphone", "filename" : "icon@180.png", "scale" : "3x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { "version" : 1, "author" : "xcode" } -} +} \ No newline at end of file diff --git a/Example/Supporting Files/Images.xcassets/Contents.json b/Example/Supporting Files/Images.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/Example/Supporting Files/Images.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Supporting Files/Images.xcassets/Icon.imageset/Contents.json b/Example/Supporting Files/Images.xcassets/Icon.imageset/Contents.json new file mode 100644 index 00000000..ec1c9ea8 --- /dev/null +++ b/Example/Supporting Files/Images.xcassets/Icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "icon@180.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Supporting Files/Images.xcassets/Icon.imageset/icon@180.png b/Example/Supporting Files/Images.xcassets/Icon.imageset/icon@180.png new file mode 100644 index 00000000..7f9d67ed Binary files /dev/null and b/Example/Supporting Files/Images.xcassets/Icon.imageset/icon@180.png differ diff --git a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/Contents.json b/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/Contents.json deleted file mode 100644 index 1ec1deec..00000000 --- a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/Contents.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "images" : [ - { - "extent" : "full-screen", - "idiom" : "iphone", - "subtype" : "736h", - "filename" : "splash-5.5.png", - "minimum-system-version" : "8.0", - "orientation" : "portrait", - "scale" : "3x" - }, - { - "extent" : "full-screen", - "idiom" : "iphone", - "subtype" : "667h", - "filename" : "splash-4.7.png", - "minimum-system-version" : "8.0", - "orientation" : "portrait", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "filename" : "splash-3.5.png", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "extent" : "full-screen", - "idiom" : "iphone", - "subtype" : "retina4", - "filename" : "splash-4.png", - "minimum-system-version" : "7.0", - "orientation" : "portrait", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-3.5.png b/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-3.5.png deleted file mode 100644 index d4232e1c..00000000 Binary files a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-3.5.png and /dev/null differ diff --git a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-4.7.png b/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-4.7.png deleted file mode 100644 index c5f37367..00000000 Binary files a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-4.7.png and /dev/null differ diff --git a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-4.png b/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-4.png deleted file mode 100644 index d7855160..00000000 Binary files a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-4.png and /dev/null differ diff --git a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-5.5.png b/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-5.5.png deleted file mode 100644 index eab7cebc..00000000 Binary files a/Example/Supporting Files/Images.xcassets/LaunchImage.launchimage/splash-5.5.png and /dev/null differ diff --git a/Example/Supporting Files/Info.plist b/Example/Supporting Files/Info.plist index 9c9f832f..6d3c94b0 100644 --- a/Example/Supporting Files/Info.plist +++ b/Example/Supporting Files/Info.plist @@ -26,6 +26,8 @@ For Science NSPhotoLibraryUsageDescription For Science + UILaunchStoryboardName + LaunchScreen UIRequiredDeviceCapabilities armv7 diff --git a/Example/Supporting Files/LaunchScreen.xib b/Example/Supporting Files/LaunchScreen.xib new file mode 100644 index 00000000..6ba24292 --- /dev/null +++ b/Example/Supporting Files/LaunchScreen.xib @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/ViewController.xib b/Example/ViewController.xib index cb3d4f40..969010cb 100644 --- a/Example/ViewController.xib +++ b/Example/ViewController.xib @@ -1,11 +1,12 @@ - + - + + @@ -31,10 +32,10 @@ - + - + - + diff --git a/README.md b/README.md index b625c76b..ed140896 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,10 @@ Add the following to your Podfile: ```ruby pod 'ALCameraViewController' +``` +> For swift 3.2 support -// For swift 3.2 support +```ruby pod 'ALCameraViewController', '~> 2.0.3' ```