点击按钮时旋转按钮,以产生类似的动画效果?
(来源: cloudfront.net)
Swift 3:
->Swift 3:
UIView.animate(withDuration: 0.25, animations: {
myButton.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
})
关于Swift中的旋转更多信息: Swift: How can you rotate text for UIButton and UILabel?
UIView.animate(withDuration: 0.25, animations: {
myButton.transform = CGAffineTransform(rotationAngle: CGFloat(M_PI_4))
}
- kuzdu[myButton setTransform:CGAffineTransformMakeRotation(M_PI_4)];
如果你想要将它旋转45度并成为一个X形状 :)
如果你想要添加动画效果,可以尝试以下代码
[UIView animateWithDuration:.5 animations:^{ myButton.transform = CGAffineTransformMakeRotation(M_PI_4); }];