diff --git a/Classes/WDCropBorderView.swift b/Classes/WDCropBorderView.swift index ef985c1..2ff3d3a 100644 --- a/Classes/WDCropBorderView.swift +++ b/Classes/WDCropBorderView.swift @@ -27,16 +27,16 @@ internal class WDCropBorderView: UIView { override func drawRect(rect: CGRect) { let context = UIGraphicsGetCurrentContext() - CGContextSetStrokeColorWithColor(context, + CGContextSetStrokeColorWithColor(context!, UIColor(red: 1, green: 1, blue: 1, alpha: 0.5).CGColor) - CGContextSetLineWidth(context, 1.5) - CGContextAddRect(context, CGRectMake(kHandleDiameter / 2, kHandleDiameter / 2, + CGContextSetLineWidth(context!, 1.5) + CGContextAddRect(context!, CGRectMake(kHandleDiameter / 2, kHandleDiameter / 2, rect.size.width - kHandleDiameter, rect.size.height - kHandleDiameter)) - CGContextStrokePath(context) + CGContextStrokePath(context!) - CGContextSetRGBFillColor(context, 1, 1, 1, 0.95) + CGContextSetRGBFillColor(context!, 1, 1, 1, 0.95) for handleRect in calculateAllNeededHandleRects() { - CGContextFillEllipseInRect(context, handleRect) + CGContextFillEllipseInRect(context!, handleRect) } } @@ -66,4 +66,4 @@ internal class WDCropBorderView: UIView { return [topLeft, topCenter, topRight, middleRight, bottomRight, bottomCenter, bottomLeft, middleLeft] } -} \ No newline at end of file +} diff --git a/Classes/WDImageCropView.swift b/Classes/WDImageCropView.swift index 7158dfe..c248518 100644 --- a/Classes/WDImageCropView.swift +++ b/Classes/WDImageCropView.swift @@ -187,7 +187,7 @@ internal class WDImageCropView: UIView, UIScrollViewDelegate { visibleRect = CGRectApplyAffineTransform(visibleRect, rectTransform); // finally crop image - let imageRef = CGImageCreateWithImageInRect(imageToCrop!.CGImage, visibleRect) + let imageRef = CGImageCreateWithImageInRect(imageToCrop!.CGImage!, visibleRect) let result = UIImage(CGImage: imageRef!, scale: imageToCrop!.scale, orientation: imageToCrop!.imageOrientation) @@ -256,4 +256,4 @@ internal class WDImageCropView: UIView, UIScrollViewDelegate { return CGAffineTransformScale(rectTransform, image.scale, image.scale) } -} \ No newline at end of file +} diff --git a/Classes/WDImageCropViewController.swift b/Classes/WDImageCropViewController.swift index b244791..d7b0e7d 100644 --- a/Classes/WDImageCropViewController.swift +++ b/Classes/WDImageCropViewController.swift @@ -53,7 +53,7 @@ internal class WDImageCropViewController: UIViewController { } func actionCancel(sender: AnyObject) { - self.navigationController?.popViewControllerAnimated(true) + self.dismissViewControllerAnimated(true, completion: nil) } func actionUse(sender: AnyObject) { @@ -64,7 +64,7 @@ internal class WDImageCropViewController: UIViewController { private func setupNavigationBar() { self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self, action: #selector(actionCancel)) - self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Use", style: .Plain, + self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Use", style: .Plain, target: self, action: #selector(actionUse)) } @@ -107,13 +107,13 @@ internal class WDImageCropViewController: UIViewController { let colorSpace = CGColorSpaceCreateDeviceRGB() let gradient = CGGradientCreateWithColorComponents(colorSpace, components, nil, 2) - CGContextDrawLinearGradient(context, gradient, CGPointMake(0, 0), CGPointMake(0, 54), []) + CGContextDrawLinearGradient(context!, gradient!, CGPointMake(0, 0), CGPointMake(0, 54), []) let viewImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() - return viewImage + return viewImage! } private func setupToolbar() { diff --git a/WDImagePicker.xcodeproj/project.pbxproj b/WDImagePicker.xcodeproj/project.pbxproj index be612e5..b9bae84 100644 --- a/WDImagePicker.xcodeproj/project.pbxproj +++ b/WDImagePicker.xcodeproj/project.pbxproj @@ -189,9 +189,11 @@ TargetAttributes = { 764FD5801B8F01C100BE5F46 = { CreatedOnToolsVersion = 6.4; + LastSwiftMigration = 0800; }; 764FD5951B8F01C100BE5F46 = { CreatedOnToolsVersion = 6.4; + LastSwiftMigration = 0800; TestTargetID = 764FD5801B8F01C100BE5F46; }; }; @@ -381,6 +383,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.wudi.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; }; name = Debug; }; @@ -392,6 +395,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.wudi.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; }; name = Release; }; @@ -408,6 +412,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.wudi.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WDImagePicker.app/WDImagePicker"; }; name = Debug; @@ -421,6 +426,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.wudi.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 2.3; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/WDImagePicker.app/WDImagePicker"; }; name = Release;