Rotate Image Animation Swift 5.

This blog is providing how to rotate image using animation. here we are using UIView animation with CGAffineTransform. code is programmatically. 



Full Code With Rotation Image:
override func viewDidLoad() {
    super.viewDidLoad()

    // ImageView with Image
    let imageV = UIImageView(frame: CGRect(x: 50, y: 100, width: 150, height: 100))
    imageV.center = view.center
    imageV.image = UIImage(named: "devImage", in: Bundle(for: type(of: self)), compatibleWith: nil)
    view.addSubview(imageV)

    // Rotation
    UIView.animate(withDuration: 2.0, animations: {
       imageV.transform = CGAffineTransform(rotationAngle: (180.0 * .pi) / 180.0)
    })

}

Rotation Output:





Thanks.


Rotate Image Animation Swift 5. Rotate Image Animation Swift 5. Reviewed by KIRIT MODI on 23:00:00 Rating: 5

No comments:

Powered by Blogger.