diff --git a/AKImageCropperView.podspec b/AKImageCropperView.podspec index bf50d32..25568d2 100644 --- a/AKImageCropperView.podspec +++ b/AKImageCropperView.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "AKImageCropperView" - s.version = "2.0.0" + s.version = "2.0.1" s.homepage = "https://github.com/artemkrachulov/AKImageCropperView" s.summary = "Responsive image cropper" s.description = <<-DESC @@ -21,5 +21,5 @@ Pod::Spec.new do |s| } s.source_files = "AKImageCropperView/*.{swift}" - s.pod_target_xcconfig = { 'SWIFT_VERSION' => '3.0' } + s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' } end \ No newline at end of file diff --git a/AKImageCropperView/AKImageCropperOverlayView.swift b/AKImageCropperView/AKImageCropperOverlayView.swift index bc7e75b..3e21ea0 100644 --- a/AKImageCropperView/AKImageCropperOverlayView.swift +++ b/AKImageCropperView/AKImageCropperOverlayView.swift @@ -487,7 +487,7 @@ open class AKImageCropperOverlayView: UIView { return } - let animations: () -> Void = { _ in + let animations: () -> Void = { self.gridView.alpha = show ? 1 : 0 } diff --git a/AKImageCropperView/AKImageCropperOverlayViewConfiguration.swift b/AKImageCropperView/AKImageCropperOverlayViewConfiguration.swift index 84b9724..39d44ec 100644 --- a/AKImageCropperView/AKImageCropperOverlayViewConfiguration.swift +++ b/AKImageCropperView/AKImageCropperOverlayViewConfiguration.swift @@ -39,11 +39,11 @@ public struct AKImageCropperCropViewConfiguration { - duration: The duration of the transition animation, measured in seconds. - options: Specifies the supported animation curves. */ - public var animation: (duration: TimeInterval, options: UIViewAnimationOptions) = (duration: 0.3, options: .curveEaseInOut) + public var animation: (duration: TimeInterval, options: UIView.AnimationOptions) = (duration: 0.3, options: .curveEaseInOut) /// Edges insets for crop rectangle. Static values for programmatically rotation. - public var cropRectInsets = UIEdgeInsetsMake(20, 20, 20, 20) + public var cropRectInsets = UIEdgeInsets(top: 20, left: 20, bottom: 20, right: 20) /// The smallest value for the crop rectangle sizes. Initial value of this property is 60 pixels width and 60 pixels height. public var minCropRectSize: CGSize = CGSize(width: 60, height: 60) diff --git a/AKImageCropperView/AKImageCropperOverlayViewConfigurationOverlay.swift b/AKImageCropperView/AKImageCropperOverlayViewConfigurationOverlay.swift index 0ffde7b..894475d 100644 --- a/AKImageCropperView/AKImageCropperOverlayViewConfigurationOverlay.swift +++ b/AKImageCropperView/AKImageCropperOverlayViewConfigurationOverlay.swift @@ -35,7 +35,7 @@ public struct AKImageCropperCropViewConfigurationOverlay { public var isBlurEnabled: Bool = true /// The intensity of the blur effect. - public var blurStyle: UIBlurEffectStyle = .dark + public var blurStyle: UIBlurEffect.Style = .dark /// The blur effect alpha value. public var blurAlpha: CGFloat = 0.6 diff --git a/AKImageCropperView/AKImageCropperScrollView.swift b/AKImageCropperView/AKImageCropperScrollView.swift index 11a9ed0..0e25082 100644 --- a/AKImageCropperView/AKImageCropperScrollView.swift +++ b/AKImageCropperView/AKImageCropperScrollView.swift @@ -15,7 +15,7 @@ final class AKImageCropperScrollView: UIScrollView { /** Return visible rect of an UIScrollView's content */ - open var visibleRect: CGRect { + public var visibleRect: CGRect { return CGRect( x : contentInset.left, y : contentInset.top, @@ -25,7 +25,7 @@ final class AKImageCropperScrollView: UIScrollView { /** Returns scaled visible rect of an UIScrollView's content */ - open var scaledVisibleRect: CGRect { + public var scaledVisibleRect: CGRect { return CGRect( x : (contentOffset.x + contentInset.left) / zoomScale, y : (contentOffset.y + contentInset.top) / zoomScale, @@ -41,7 +41,7 @@ final class AKImageCropperScrollView: UIScrollView { return view }() - open var image: UIImage! { + public var image: UIImage! { didSet { /* Prepare scroll view to changing the image */ diff --git a/AKImageCropperView/AKImageCropperView.swift b/AKImageCropperView/AKImageCropperView.swift index c13c531..a747fb8 100644 --- a/AKImageCropperView/AKImageCropperView.swift +++ b/AKImageCropperView/AKImageCropperView.swift @@ -40,7 +40,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer fileprivate var reversedRect: CGRect { return CGRect( origin : .zero, - size : ((angle / M_PI_2).truncatingRemainder(dividingBy: 2)) == 1 + size : ((angle / Double.pi / 2).truncatingRemainder(dividingBy: 2)) == 1 ? CGSize(width: frame.size.height, height: frame.size.width) : frame.size) } @@ -52,24 +52,24 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer var newEdgeInsets: UIEdgeInsets switch angle { - case M_PI_2: - newEdgeInsets = UIEdgeInsetsMake( - minEdgeInsets.right, - minEdgeInsets.top, - minEdgeInsets.left, - minEdgeInsets.bottom) - case M_PI: - newEdgeInsets = UIEdgeInsetsMake( - minEdgeInsets.bottom, - minEdgeInsets.right, - minEdgeInsets.top, - minEdgeInsets.left) - case M_PI_2 * 3: - newEdgeInsets = UIEdgeInsetsMake( - minEdgeInsets.left, - minEdgeInsets.bottom, - minEdgeInsets.right, - minEdgeInsets.top) + case Double.pi / 2: + newEdgeInsets = UIEdgeInsets( + top: minEdgeInsets.right, + left: minEdgeInsets.top, + bottom: minEdgeInsets.left, + right: minEdgeInsets.bottom) + case Double.pi: + newEdgeInsets = UIEdgeInsets( + top: minEdgeInsets.bottom, + left: minEdgeInsets.right, + bottom: minEdgeInsets.top, + right: minEdgeInsets.left) + case Double.pi / 2 * 3: + newEdgeInsets = UIEdgeInsets( + top: minEdgeInsets.left, + left: minEdgeInsets.bottom, + bottom: minEdgeInsets.right, + right: minEdgeInsets.top) default: newEdgeInsets = minEdgeInsets } @@ -80,7 +80,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer /** Reversed frame + edgeInsets direct to current rotation angle */ var reversedFrameWithInsets: CGRect { - return UIEdgeInsetsInsetRect(reversedRect, reversedEdgeInsets) + return reversedRect.inset(by: reversedEdgeInsets) } // MARK: - @@ -427,7 +427,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer - Parameter completion: A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL. */ - open func showOverlayView(animationDuration duration: TimeInterval = 0, options: UIViewAnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) { + open func showOverlayView(animationDuration duration: TimeInterval = 0, options: UIView.AnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) { guard let image = image, let overlayView = overlayView, !isOverlayViewActive && !isAnimation else { return @@ -437,7 +437,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer savedProperty.save(scrollView: scrollView) cancelZoomingTimer() - let _animations: () -> Void = { _ in + let _animations: () -> Void = { self.layoutSubviews() @@ -492,7 +492,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer - Parameter completion: A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL. */ - open func hideOverlayView(animationDuration duration: TimeInterval = 0, options: UIViewAnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) { + open func hideOverlayView(animationDuration duration: TimeInterval = 0, options: UIView.AnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) { guard let image = image, let overlayView = overlayView, isOverlayViewActive && !isAnimation else { return @@ -504,7 +504,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer isAnimation = true - let _animations: () -> Void = { _ in + let _animations: () -> Void = { self.layoutSubviews() @@ -561,16 +561,16 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer - Parameter completion: A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL. */ - open func rotate(_ angle: Double, withDuration duration: TimeInterval = 0, options: UIViewAnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) { + open func rotate(_ angle: Double, withDuration duration: TimeInterval = 0, options: UIView.AnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) { - guard angle.truncatingRemainder(dividingBy: M_PI_2) == 0 else { + guard angle.truncatingRemainder(dividingBy: Double.pi / 2) == 0 else { return } self.angle = angle savedProperty.save(scrollView: scrollView) - let _animations: () -> Void = { _ in + let _animations: () -> Void = { self.rotateView.transform = CGAffineTransform(rotationAngle: CGFloat(angle)) self.layoutSubviews() @@ -600,7 +600,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer - Parameter completion: A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL. */ - open func reset(animationDuration duration: TimeInterval = 0, options: UIViewAnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) { + open func reset(animationDuration duration: TimeInterval = 0, options: UIView.AnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) { guard !isAnimation else { return @@ -610,7 +610,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer angle = 0 cancelZoomingTimer() - let _animations: () -> Void = { _ in + let _animations: () -> Void = { self.rotateView.transform = CGAffineTransform.identity @@ -705,11 +705,11 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer // Fix insets direct to orientation - return UIEdgeInsetsMake( - center.y + minEdgeInsets.top, - center.x + minEdgeInsets.left, - center.y + minEdgeInsets.bottom, - center.x + minEdgeInsets.right) + return UIEdgeInsets( + top: center.y + minEdgeInsets.top, + left: center.x + minEdgeInsets.left, + bottom: center.y + minEdgeInsets.bottom, + right: center.x + minEdgeInsets.right) } private func contentOffset(from savedContentOffsetPercentage: CGPointPercentage) -> CGPoint { @@ -732,11 +732,11 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer func cropperOverlayViewDidChangeCropRect(_ view: AKImageCropperOverlayView, _ cropRect: CGRect) { - scrollView.contentInset = UIEdgeInsetsMake( - cropRect.origin.y, - cropRect.origin.x, - view.frame.size.height - cropRect.size.height - cropRect.origin.y, - view.frame.size.width - cropRect.size.width - cropRect.origin.x) + scrollView.contentInset = UIEdgeInsets( + top: cropRect.origin.y, + left: cropRect.origin.x, + bottom: view.frame.size.height - cropRect.size.height - cropRect.origin.y, + right: view.frame.size.width - cropRect.size.width - cropRect.origin.x) if cropRect.size.height > scrollView.contentSize.height || cropRect.size.width > scrollView.contentSize.width { diff --git a/AKImageCropperView/Info.plist b/AKImageCropperView/Info.plist index d87c8b3..0e27f5f 100644 --- a/AKImageCropperView/Info.plist +++ b/AKImageCropperView/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.0 + 2.0.1 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/README.md b/README.md index 844251a..4e69d02 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ [carthage-url]: https://github.com/Carthage/Carthage [platform-bage]: https://img.shields.io/cocoapods/p/LFAlertController.svg [platform-url]: http://cocoapods.org/pods/LFAlertController -[swift-bage]:https://img.shields.io/badge/swift-3.0-orange.svg +[swift-bage]:https://img.shields.io/badge/swift-5.0-orange.svg [swift-url]: https://swift.org/ [license-bage]: https://img.shields.io/badge/License-MIT-blue.svg [license-url]: LICENSE