How to programmatically rotate the view by 180 degrees in my iPhone App?
As ’CGAffineTransformRotate’ uses radians as its unit of measure, and 180 degrees is the same as PI, instead of the math provided in other answers you can simply do:
view.transform = CGAffineTransformRotate(view.transform, M_PI);
Swift 3:
view.transform = view.transform.rotated(by: .pi)
If you plan on doing a lot of transforms, it's probably best to read up on radians, so you understand what is going on.