Ich spiele mit dem Drehen eines UIImageView herum. Die Rotationsanimation funktioniert gut, aber am Ende, wenn das Bild in seine ursprüngliche Ausrichtung zurückkehrt. Im Folgenden finden Sie eine Erweiterung ich es drehen verwenden:iOS Schnelle Drehanimation bleibt nicht stehen
extension UIView {
func rotate(duration: CFTimeInterval = 1.0, degrees:Double, completionDelegate: AnyObject? = nil) {
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
rotateAnimation.fromValue = 0.0
let radians = CGFloat(degrees * M_PI/degrees)
rotateAnimation.toValue = CGFloat(radians)
rotateAnimation.duration = duration
if let delegate: AnyObject = completionDelegate {
rotateAnimation.delegate = delegate
}
self.layer.addAnimation(rotateAnimation, forKey: nil)
}
}
Ich habe Auto-Layout ausgeschaltet. Was vermisse ich?