我发现这个代码允许你在Swift中按下按钮时旋转/旋转90度.但我想要做的是在按下按钮时无限旋转/旋转按钮,并在再次按下按钮时停止旋转.这是我的代码:
import UIKit
class ViewController: UIViewController {
@IBOutlet var otherbutton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func Rotate(sender: AnyObject) {
UIView.animateWithDuration(1.0,
animations: ({
self.otherbutton.transform = CGAffineTransformMakeRotation(90)
}))
}
}
Run Code Online (Sandbox Code Playgroud)