Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M_PI removed, swift 3.0 error fixed #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
10 changes: 5 additions & 5 deletions AKImageCropperView/AKImageCropperView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -52,19 +52,19 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer
var newEdgeInsets: UIEdgeInsets

switch angle {
case M_PI_2:
case Double.pi/2:
newEdgeInsets = UIEdgeInsetsMake(
minEdgeInsets.right,
minEdgeInsets.top,
minEdgeInsets.left,
minEdgeInsets.bottom)
case M_PI:
case Double.pi:
newEdgeInsets = UIEdgeInsetsMake(
minEdgeInsets.bottom,
minEdgeInsets.right,
minEdgeInsets.top,
minEdgeInsets.left)
case M_PI_2 * 3:
case Double.pi/2 * 3:
newEdgeInsets = UIEdgeInsetsMake(
minEdgeInsets.left,
minEdgeInsets.bottom,
Expand Down Expand Up @@ -563,7 +563,7 @@ open class AKImageCropperView: UIView, UIScrollViewDelegate, UIGestureRecognizer

open func rotate(_ angle: Double, withDuration duration: TimeInterval = 0, options: UIViewAnimationOptions = .curveEaseInOut, completion: ((Bool) -> Void)? = nil) {

guard angle.truncatingRemainder(dividingBy: M_PI_2) == 0 else {
guard angle.truncatingRemainder(dividingBy: Double.pi/2) == 0 else {
return
}

Expand Down
6 changes: 3 additions & 3 deletions AKImageCropperViewExample/CropperViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ final class CropperViewController: UIViewController {

@IBAction func showHideOverlayAction(_ sender: AnyObject) {

if cropView.isoverlayViewActive {
if cropView.isOverlayViewActive {

cropView.hideOverlayView(animationDuration: 0.3)

Expand All @@ -111,11 +111,11 @@ final class CropperViewController: UIViewController {

@IBAction func rotateAction(_ sender: AnyObject) {

angle += M_PI_2
angle += Double.pi/2

cropView.rotate(angle, withDuration: 0.3, completion: { _ in

if self.angle == 2 * M_PI {
if self.angle == 2 * Double.pi {
self.angle = 0.0
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class CustomImageCropperOverlayView: AKImageCropperOverlayView {
arcCenter: CGPoint(x: touchView.bounds.midX, y: touchView.bounds.midY),
radius: width,
startAngle: 0.0,
endAngle: CGFloat(M_PI * 2),
endAngle: CGFloat(Double.pi * 2),
clockwise: true)

layer.path = circlePath.cgPath
Expand Down