Skip to content

Commit

Permalink
swift 4.2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jari Kalinainen committed Sep 21, 2018
1 parent bc24270 commit 8e68657
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

11 changes: 8 additions & 3 deletions Example/CropperExample/CropperExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
Expand Down Expand Up @@ -187,13 +188,15 @@
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;
CLANG_WARN_ENUM_CONVERSION = YES;
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;
Expand Down Expand Up @@ -244,13 +247,15 @@
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;
CLANG_WARN_ENUM_CONVERSION = YES;
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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Example/CropperExample/CropperExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
19 changes: 10 additions & 9 deletions UIImageCropper.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,27 @@
#

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?
# * Try to keep it short, snappy and to the point.
# * 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'

Expand Down
32 changes: 16 additions & 16 deletions UIImageCropper/UIImageCropper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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
}
Expand All @@ -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)
}
Expand All @@ -255,7 +255,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
} else {
self.endAppearanceTransition()
self.view.removeFromSuperview()
self.removeFromParentViewController()
self.removeFromParent()
}
}

Expand Down Expand Up @@ -312,22 +312,22 @@ 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
presenting = true
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)
}
}

}

Expand Down

0 comments on commit 8e68657

Please sign in to comment.