Skip to content
This repository was archived by the owner on Apr 6, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Classes/WDCropBorderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -66,4 +66,4 @@ internal class WDCropBorderView: UIView {
return [topLeft, topCenter, topRight, middleRight, bottomRight, bottomCenter, bottomLeft,
middleLeft]
}
}
}
4 changes: 2 additions & 2 deletions Classes/WDImageCropView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -256,4 +256,4 @@ internal class WDImageCropView: UIView, UIScrollViewDelegate {

return CGAffineTransformScale(rectTransform, image.scale, image.scale)
}
}
}
8 changes: 4 additions & 4 deletions Classes/WDImageCropViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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))
}

Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 6 additions & 0 deletions WDImagePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@
TargetAttributes = {
764FD5801B8F01C100BE5F46 = {
CreatedOnToolsVersion = 6.4;
LastSwiftMigration = 0800;
};
764FD5951B8F01C100BE5F46 = {
CreatedOnToolsVersion = 6.4;
LastSwiftMigration = 0800;
TestTargetID = 764FD5801B8F01C100BE5F46;
};
};
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
Expand All @@ -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;
Expand Down