Skip to content

Commit 8e68657

Browse files
author
Jari Kalinainen
committed
swift 4.2 update
1 parent bc24270 commit 8e68657

5 files changed

Lines changed: 35 additions & 30 deletions

File tree

.swift-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

Example/CropperExample/CropperExample.xcodeproj/project.pbxproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,12 @@
9999
isa = PBXProject;
100100
attributes = {
101101
LastSwiftUpdateCheck = 0920;
102-
LastUpgradeCheck = 0920;
102+
LastUpgradeCheck = 1000;
103103
ORGANIZATIONNAME = "Jari Kalinainen";
104104
TargetAttributes = {
105105
49B955051FF5795B00BA9181 = {
106106
CreatedOnToolsVersion = 9.2;
107+
LastSwiftMigration = 1000;
107108
ProvisioningStyle = Automatic;
108109
};
109110
};
@@ -187,13 +188,15 @@
187188
CLANG_WARN_BOOL_CONVERSION = YES;
188189
CLANG_WARN_COMMA = YES;
189190
CLANG_WARN_CONSTANT_CONVERSION = YES;
191+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
190192
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
191193
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
192194
CLANG_WARN_EMPTY_BODY = YES;
193195
CLANG_WARN_ENUM_CONVERSION = YES;
194196
CLANG_WARN_INFINITE_RECURSION = YES;
195197
CLANG_WARN_INT_CONVERSION = YES;
196198
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
199+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
197200
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
198201
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
199202
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -244,13 +247,15 @@
244247
CLANG_WARN_BOOL_CONVERSION = YES;
245248
CLANG_WARN_COMMA = YES;
246249
CLANG_WARN_CONSTANT_CONVERSION = YES;
250+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
247251
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
248252
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
249253
CLANG_WARN_EMPTY_BODY = YES;
250254
CLANG_WARN_ENUM_CONVERSION = YES;
251255
CLANG_WARN_INFINITE_RECURSION = YES;
252256
CLANG_WARN_INT_CONVERSION = YES;
253257
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
258+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
254259
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
255260
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
256261
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -291,7 +296,7 @@
291296
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
292297
PRODUCT_BUNDLE_IDENTIFIER = com.klubitii.CropperExample;
293298
PRODUCT_NAME = "$(TARGET_NAME)";
294-
SWIFT_VERSION = 4.0;
299+
SWIFT_VERSION = 4.2;
295300
TARGETED_DEVICE_FAMILY = "1,2";
296301
};
297302
name = Debug;
@@ -307,7 +312,7 @@
307312
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
308313
PRODUCT_BUNDLE_IDENTIFIER = com.klubitii.CropperExample;
309314
PRODUCT_NAME = "$(TARGET_NAME)";
310-
SWIFT_VERSION = 4.0;
315+
SWIFT_VERSION = 4.2;
311316
TARGETED_DEVICE_FAMILY = "1,2";
312317
};
313318
name = Release;

Example/CropperExample/CropperExample/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}

UIImageCropper.podspec

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@
77
#
88

99
Pod::Spec.new do |s|
10-
s.name = 'UIImageCropper'
11-
s.version = '1.3.4'
12-
s.summary = 'Simple Image cropper for UIImage and UIImagePickerController with customisable aspect ratio.'
10+
s.name = 'UIImageCropper'
11+
s.version = '1.4.0'
12+
s.summary = 'Simple Image cropper for UIImage and UIImagePickerController with customisable aspect ratio.'
1313

1414
# This description is used to generate tags and improve search results.
1515
# * Think: What does it do? Why did you write it? What is the focus?
1616
# * Try to keep it short, snappy and to the point.
1717
# * Write the description between the DESC delimiters below.
1818
# * Finally, don't worry about the indent, CocoaPods strips it!
1919

20-
s.description = <<-DESC
21-
Simple Image cropper for UIImage and UIImagePickerController with customisable crop aspect ratio. Made purely with Swift4!
20+
s.description = <<-DESC
21+
Simple Image cropper for UIImage and UIImagePickerController with customisable crop aspect ratio. Made purely with Swift!
2222
Replaces the iOS "crop only to square" functionality. Easy few line setup with delegate method. With possibility to localized button texts.
2323
See example for usage details.
2424
DESC
2525

26-
s.homepage = 'https://github.com/jvk75/UIImageCropper'
27-
s.license = { :type => 'MIT', :file => 'LICENSE' }
28-
s.author = { 'Jari Kalinainen' => 'jari@klubitii.com' }
29-
s.source = { :git => 'https://github.com/jvk75/UIImageCropper.git', :tag => s.version.to_s }
26+
s.homepage = 'https://github.com/jvk75/UIImageCropper'
27+
s.license = { :type => 'MIT', :file => 'LICENSE' }
28+
s.author = { 'Jari Kalinainen' => 'jari@klubitii.com' }
29+
s.source = { :git => 'https://github.com/jvk75/UIImageCropper.git', :tag => s.version.to_s }
30+
s.swift_version = '4.2'
3031

3132
s.ios.deployment_target = '10.0'
3233

UIImageCropper/UIImageCropper.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
105105
self.view.addSubview(bottomView)
106106
topView.translatesAutoresizingMaskIntoConstraints = false
107107
bottomView.translatesAutoresizingMaskIntoConstraints = false
108-
let horizontalTopConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": topView])
109-
let horizontalBottomConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": bottomView])
110-
let verticalConst = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(0)-[top]-(0)-[bottom(70)]-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["bottom": bottomView, "top": topView])
108+
let horizontalTopConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": topView])
109+
let horizontalBottomConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": bottomView])
110+
let verticalConst = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(0)-[top]-(0)-[bottom(70)]-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["bottom": bottomView, "top": topView])
111111
self.view.addConstraints(horizontalTopConst + horizontalBottomConst + verticalConst)
112112

113113
// image view
@@ -138,8 +138,8 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
138138
fadeView.isUserInteractionEnabled = false
139139
fadeView.backgroundColor = UIColor.black.withAlphaComponent(0.3)
140140
topView.addSubview(fadeView)
141-
let horizontalFadeConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": fadeView])
142-
let verticalFadeConst = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(0)-[view]-(0)-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": fadeView])
141+
let horizontalFadeConst = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(0)-[view]-(0)-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": fadeView])
142+
let verticalFadeConst = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(0)-[view]-(0)-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": fadeView])
143143
topView.addConstraints(horizontalFadeConst + verticalFadeConst)
144144

145145
// crop overlay
@@ -177,7 +177,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
177177
let centerCropYConst = NSLayoutConstraint(item: cropButton, attribute: .centerY, relatedBy: .equal, toItem: bottomView, attribute: .centerY, multiplier: 1, constant: 0)
178178
bottomView.addConstraints([centerCropXConst, centerCropYConst])
179179

180-
self.view.bringSubview(toFront: bottomView)
180+
self.view.bringSubviewToFront(bottomView)
181181

182182
bottomView.layoutIfNeeded()
183183
topView.layoutIfNeeded()
@@ -209,8 +209,8 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
209209
imageHeightConst?.constant = cropView.frame.width * ratio
210210
}
211211

212-
let horizontal = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(<=\(cropView.frame.origin.x))-[view]-(<=\(cropView.frame.origin.x))-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": imageView])
213-
let vertical = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(<=\(cropView.frame.origin.y))-[view]-(<=\(cropView.frame.origin.y))-|", options: NSLayoutFormatOptions(), metrics: nil, views: ["view": imageView])
212+
let horizontal = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(<=\(cropView.frame.origin.x))-[view]-(<=\(cropView.frame.origin.x))-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": imageView])
213+
let vertical = NSLayoutConstraint.constraints(withVisualFormat: "V:|-(<=\(cropView.frame.origin.y))-[view]-(<=\(cropView.frame.origin.y))-|", options: NSLayoutConstraint.FormatOptions(), metrics: nil, views: ["view": imageView])
214214
topView.addConstraints(horizontal + vertical)
215215

216216
maskFadeView()
@@ -222,7 +222,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
222222
let path = UIBezierPath(rect: cropView.frame)
223223
path.append(UIBezierPath(rect: fadeView.frame))
224224
let mask = CAShapeLayer()
225-
mask.fillRule = kCAFillRuleEvenOdd
225+
mask.fillRule = CAShapeLayerFillRule.evenOdd
226226
mask.path = path.cgPath
227227
fadeView.layer.mask = mask
228228
}
@@ -240,7 +240,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
240240
} else {
241241
self.endAppearanceTransition()
242242
self.view.removeFromSuperview()
243-
self.removeFromParentViewController()
243+
self.removeFromParent()
244244
if self.autoClosePicker {
245245
self.picker?.dismiss(animated: true, completion: nil)
246246
}
@@ -255,7 +255,7 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
255255
} else {
256256
self.endAppearanceTransition()
257257
self.view.removeFromSuperview()
258-
self.removeFromParentViewController()
258+
self.removeFromParent()
259259
}
260260
}
261261

@@ -312,22 +312,22 @@ public class UIImageCropper: UIViewController, UIImagePickerControllerDelegate,
312312

313313
var presenting = false
314314

315-
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
315+
public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
316316
guard !presenting else {
317317
return
318318
}
319-
guard let image = info[UIImagePickerControllerOriginalImage] as? UIImage else {
319+
guard let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage else {
320320
return
321321
}
322322
layoutDone = false
323323
presenting = true
324324
self.image = image.fixOrientation()
325325
self.picker?.view.addSubview(self.view)
326326
self.view.constraintToFill(superView: self.picker?.view)
327-
self.picker?.addChildViewController(self)
328-
self.willMove(toParentViewController: self.picker)
327+
self.picker?.addChild(self)
328+
self.willMove(toParent: self.picker)
329329
self.beginAppearanceTransition(true, animated: false)
330-
}
330+
}
331331

332332
}
333333

0 commit comments

Comments
 (0)