Rotate UIButton 360 degrees

后端 未结 8 1018
青春惊慌失措
青春惊慌失措 2021-02-07 01:52

I\'ve been trying to run an animation that rotates my UIButton 360 degrees using this code:

UIView.animateWithDuration(3.0, animations: {
  self.vin         


        
8条回答
  •  忘了有多久
    2021-02-07 02:10

    Swift 4 version that allows you to rotate the same view infinite times:

    UIView.animate(withDuration: 0.5) {
      self.yourButton.transform = self.yourButton.transform.rotated(by: CGFloat.pi)
    }
    

    if you want to rotate 360°:

    UIView.animate(withDuration: 0.5) {
      self.yourButton.transform = self.yourButton.transform.rotated(by: CGFloat.pi)
      self.yourButton.transform = self.yourButton.transform.rotated(by: CGFloat.pi)
    }
    

提交回复
热议问题