diff --git a/.swift-version b/.swift-version deleted file mode 100644 index b8626c4..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4 diff --git a/Example/CropperExample/CropperExample.xcodeproj/project.pbxproj b/Example/CropperExample/CropperExample.xcodeproj/project.pbxproj index 46bc179..e3b246e 100644 --- a/Example/CropperExample/CropperExample.xcodeproj/project.pbxproj +++ b/Example/CropperExample/CropperExample.xcodeproj/project.pbxproj @@ -99,11 +99,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 0920; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "Jari Kalinainen"; TargetAttributes = { 49B955051FF5795B00BA9181 = { CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1000; ProvisioningStyle = Automatic; }; }; @@ -187,6 +188,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -194,6 +196,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -244,6 +247,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -251,6 +255,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -291,7 +296,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.klubitii.CropperExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -307,7 +312,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.klubitii.CropperExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/Example/CropperExample/CropperExample/AppDelegate.swift b/Example/CropperExample/CropperExample/AppDelegate.swift index f08294b..e9fbbdb 100644 --- a/Example/CropperExample/CropperExample/AppDelegate.swift +++ b/Example/CropperExample/CropperExample/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/UIImageCropper.podspec b/UIImageCropper.podspec index c0a18fb..25e4fa7 100644 --- a/UIImageCropper.podspec +++ b/UIImageCropper.podspec @@ -7,9 +7,9 @@ # Pod::Spec.new do |s| - s.name = 'UIImageCropper' - s.version = '1.3.4' - s.summary = 'Simple Image cropper for UIImage and UIImagePickerController with customisable aspect ratio.' + s.name = 'UIImageCropper' + s.version = '1.4.0' + s.summary = 'Simple Image cropper for UIImage and UIImagePickerController with customisable aspect ratio.' # This description is used to generate tags and improve search results. # * Think: What does it do? Why did you write it? What is the focus? @@ -17,16 +17,17 @@ Pod::Spec.new do |s| # * Write the description between the DESC delimiters below. # * Finally, don't worry about the indent, CocoaPods strips it! - s.description = <<-DESC -Simple Image cropper for UIImage and UIImagePickerController with customisable crop aspect ratio. Made purely with Swift4! + s.description = <<-DESC +Simple Image cropper for UIImage and UIImagePickerController with customisable crop aspect ratio. Made purely with Swift! Replaces the iOS "crop only to square" functionality. Easy few line setup with delegate method. With possibility to localized button texts. See example for usage details. DESC - s.homepage = 'https://github.com/jvk75/UIImageCropper' - s.license = { :type => 'MIT', :file => 'LICENSE' } - s.author = { 'Jari Kalinainen' => 'jari@klubitii.com' } - s.source = { :git => 'https://github.com/jvk75/UIImageCropper.git', :tag => s.version.to_s } + s.homepage = 'https://github.com/jvk75/UIImageCropper' + s.license = { :type => 'MIT', :file => 'LICENSE' } + s.author = { 'Jari Kalinainen' => 'jari@klubitii.com' } + s.source = { :git => 'https://github.com/jvk75/UIImageCropper.git', :tag => s.version.to_s } + s.swift_version = '4.2' s.ios.deployment_target = '10.0' diff --git a/UIImageCropper/UIImageCropper.swift b/UIImageCropper/UIImageCropper.swift index a5e7857..60d5ef9 100644 --- a/UIImageCropper/UIImageCropper.swift +++ b/UIImageCropper/UIImageCropper.swift @@ -105,9 +105,9 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, self.view.addSubview(bottomView) topView.translatesAutoresizingMaskIntoConstraints = false bottomView.translatesAutoresizingMaskIntoConstraints = false - let horizontalTopConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": topView]) - let horizontalBottomConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": bottomView]) - let verticalConst = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(0)-[top]-(0)-[bottom(70)]-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["bottom": bottomView, "top": topView]) + let horizontalTopConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": topView]) + let horizontalBottomConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": bottomView]) + let verticalConst = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(0)-[top]-(0)-[bottom(70)]-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["bottom": bottomView, "top": topView]) self.view.addConstraints(horizontalTopConst + horizontalBottomConst + verticalConst) // image view @@ -138,8 +138,8 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, fadeView.isUserInteractionEnabled = false fadeView.backgroundColor = UIColor.black.withAlphaComponent(0.3) topView.addSubview(fadeView) - let horizontalFadeConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": fadeView]) - let verticalFadeConst = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(0)-[view]-(0)-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": fadeView]) + let horizontalFadeConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": fadeView]) + let verticalFadeConst = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(0)-[view]-(0)-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": fadeView]) topView.addConstraints(horizontalFadeConst + verticalFadeConst) // crop overlay @@ -177,7 +177,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, let centerCropYConst = NSLayoutConstraint(item: cropButton, attribute: .centerY, relatedBy: .equal, toItem: bottomView, attribute: .centerY, multiplier: 1, constant: 0) bottomView.addConstraints([centerCropXConst, centerCropYConst]) - self.view.bringSubview(toFront: bottomView) + self.view.bringSubviewToFront(bottomView) bottomView.layoutIfNeeded() topView.layoutIfNeeded() @@ -209,8 +209,8 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, imageHeightConst?.constant = cropView.frame.width * ratio } - let horizontal = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(<=\(cropView.frame.origin.x))-[view]-(<=\(cropView.frame.origin.x))-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": imageView]) - let vertical = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(<=\(cropView.frame.origin.y))-[view]-(<=\(cropView.frame.origin.y))-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": imageView]) + let horizontal = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(<=\(cropView.frame.origin.x))-[view]-(<=\(cropView.frame.origin.x))-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": imageView]) + let vertical = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(<=\(cropView.frame.origin.y))-[view]-(<=\(cropView.frame.origin.y))-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": imageView]) topView.addConstraints(horizontal + vertical) maskFadeView() @@ -222,7 +222,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, let path = UIBezierPath(rect: cropView.frame) path.append(UIBezierPath(rect: fadeView.frame)) let mask = CAShapeLayer() - mask.fillRule = kCAFillRuleEvenOdd + mask.fillRule = CAShapeLayerFillRule.evenOdd mask.path = path.cgPath fadeView.layer.mask = mask } @@ -240,7 +240,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, } else { self.endAppearanceTransition() self.view.removeFromSuperview() - self.removeFromParentViewController() + self.removeFromParent() if self.autoClosePicker { self.picker?.dismiss(animated: true, completion: nil) } @@ -255,7 +255,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, } else { self.endAppearanceTransition() self.view.removeFromSuperview() - self.removeFromParentViewController() + self.removeFromParent() } } @@ -312,11 +312,11 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, var presenting = false - public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { + public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { guard !presenting else { return } - guard let image = info[UIImagePickerControllerOriginalImage] as? UIImage else { + guard let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage else { return } layoutDone = false @@ -324,10 +324,10 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate, self.image = image.fixOrientation() self.picker?.view.addSubview(self.view) self.view.constraintToFill(superView: self.picker?.view) - self.picker?.addChildViewController(self) - self.willMove(toParentViewController: self.picker) + self.picker?.addChild(self) + self.willMove(toParent: self.picker) self.beginAppearanceTransition(true, animated: false) - } + } }