Rotate the image 180 degrees

I have one image similar to disclosure. Initially, it will look like a drop-down image. Therefore, when the user pops up a drop-down list, some parameter will be shown. So what I need is when the dropdown menu is true. I mean, when the user clicks the dropdown image, and when the list of options is displayed down, I need to show the dropdown image 180 degrees. Same as falling down, false. it is necessary to show the image as a normal position.

Is this method correct and not use another image? I am using fast 2.2

Updated:

 @IBAction func dropBtnPress(sender: AnyObject) {

            if dropDown.hidden {
                dropDown.show()
                UIView.animateWithDuration(0.0, animations: {
                    self.image.transform = CGAffineTransformMakeRotation((180.0 * CGFloat(M_PI)) / 180.0)
                })
            } else {
                dropDown.hide()
    //            UIView.animateWithDuration(2.0, animations: {
    //                self.image.transform = CGAffineTransformMakeRotation((180.0 * CGFloat(M_PI)) / -180.0)
    //            })
            }
        }

    }
+4
source share
3 answers

, :

UIView.animateWithDuration(2.0, animations: {
     self.imageView.transform = CGAffineTransformMakeRotation(CGFloat(M_PI))
})

( 2.0).

, :

UIView.animateWithDuration(2.0, animations: {
     self.imageV.transform = CGAffineTransform.identity
})

Swift 4.x:

:

UIView.animate(withDuration: 2.0, animations: {
    self.imageView.transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi))
})

:

UIView.animate(withDuration: 2.0, animations: {
    self.imageView.transform = CGAffineTransform.identity
})
+15

Swift 3

UIView.animate(withDuration:0.1, animations: {
     self.arrowIcon.transform = CGAffineTransform(rotationAngle: (180.0 * CGFloat(Double.pi)) / 180.0)
})
+5

, 180 , . 180 pi. 360 - 2 * pi. 180 * pi 90 .

- ,

let rotationAnimation = CABasicAnimation(keyPath: "transform.rotation")
rotationAnimation.fromValue = 0.0
rotationAnimation.toValue = M_PI
rotationAnimation.duration = 1.0

self.arrowImageView.layer.addAnimation(rotationAnimation, forKey: nil)

, :)

+3
source

All Articles