小编Chr*_*man的帖子

旋转按钮无限:Swift

我发现这个代码允许你在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)

xcode swift

1
推荐指数
1
解决办法
1377
查看次数

标签 统计

swift ×1

xcode ×1