How to programmatically rotate the view by 180 degrees in my iPhone App?
Swift 4:
self.view.transform = CGAffineTransform(rotationAngle: .pi);
And a COMMENT (I evidently don't have enough points to enter my comment on his/her answer) for Benjamin Mayo or vtcajones answer of:
view.transform = view.transform.rotated(by: .pi)
This will work the first time, but the next time it is called it will rotate the view again, back to the original rotation, which is probably not what you want. It would be safer to set the transform value exactly each time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With