Skip to content

Instantly share code, notes, and snippets.

@sxcore
sxcore / UIImage+Rotation.swift
Last active March 21, 2018 19:00 — forked from ffried/UIImage+Rotation.swift
Swift 4.0 updated version, without "bangs" and with proper variable naming.
extension UIImage {
func rotate(degrees: CGFloat) -> UIImage? {
let degreesToRadians: (CGFloat) -> CGFloat = {
return $0 / 180.0 * .pi
}
let rotatedViewBox = UIView(frame: CGRect(origin: CGPoint(x:0, y:0), size: size))
let transformation = CGAffineTransform(rotationAngle: degreesToRadians(degrees))