meetpd meetpd - 1 year ago 70
Objective-C Question

Is it possible to programatically rotate the view by 180 degrees?

In my iPhone App, I want to programatically rotate the view by 180 degrees.

Is that possible, if yes how?

Thanks!

Answer Source

Should be possible by using CGAffineTransform

Quote from this question, this should do the trick:

CGFloat radians = atan2f(yourView.transform.b, yourView.transform.a);
CGFloat degrees = radians * (180 / M_PI);
CGAffineTransform transform = CGAffineTransformMakeRotation((90 + degrees) * M_PI/180);
yourView.transform = transform;