How to rotate image in Swift?

后端 未结 13 1243
萌比男神i
萌比男神i 2020-11-30 03:55

I am unable to rotate the image by 90 degrees in swift. I have written below code but there is an error and doesn\'t compile

  func imageRotatedByDegrees(old         


        
13条回答
  •  爱一瞬间的悲伤
    2020-11-30 04:13

    In Swift 4.2 and Xcode 10.0

    dropDownImageView.transform = dropDownImageView.transform.rotated(by: CGFloat(Double.pi / 2))
    

    If you want to add animation...

    UIView.animate(withDuration: 2.0, animations: {
       self.dropDownImageView.transform = self.dropDownImageView.transform.rotated(by: CGFloat(Double.pi / 2))
    })
    

提交回复
热议问题