Skip to content

Instantly share code, notes, and snippets.

@giginet
Last active September 2, 2018 04:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giginet/33f00a3bef859afca289fe5aa08a935c to your computer and use it in GitHub Desktop.
Save giginet/33f00a3bef859afca289fe5aa08a935c to your computer and use it in GitHub Desktop.
import UIKit
postfix operator °
protocol IntegerInitializable: ExpressibleByIntegerLiteral {
init (_: Int)
}
extension Int: IntegerInitializable {
postfix public static func °(lhs: Int) -> CGFloat {
return CGFloat(Measurement(value: Double(lhs), unit: UnitAngle.degrees)
.converted(to: .radians).value)
}
}
let angle = 45°
let contentView = UIView()
contentView.transform = CGAffineTransform(rotationAngle: 45°)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment