xcode 快速按钮旋转动画以制作类似的动画
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31843485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Button Rotation Animation in swift to make a similar Animation
提问by Omar Shiltawi
Rotate a button to make a similar animation when clicked?
单击时旋转按钮以制作类似的动画?
(source: cloudfront.net)
(来源:cloudfront.net)
回答by Caleb
Swift 3:
斯威夫特3:
UIView.animate(withDuration: 0.25, animations: {
myButton.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
})
More information on rotation in Swift: Swift: How can you rotate text for UIButton and UILabel?
有关 Swift 中旋转的更多信息: Swift:如何为 UIButton 和 UILabel 旋转文本?
回答by dorian
You can use a regular rotation on the button:
您可以在按钮上使用常规旋转:
[myButton setTransform:CGAffineTransformMakeRotation(M_PI_4)];
that would rotat + a 45degrees and make it an X :)
那将旋转+ 45度并使其成为X :)
if you want to animate as well try
如果您也想制作动画,请尝试
[UIView animateWithDuration:.5 animations:^{
myButton.transform = CGAffineTransformMakeRotation(M_PI_4);
}];