Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rotate UIViews?

The Twitter app is a tab bar app on the iPhone. Nothing in any of the tabs will rotate, yet, when you click on a link from a tweet, the view controller that is pushed on top of it IS allowed to rotate. The only rotations I have ever doe is from tilting the device, landscape or portrait, but I don't understand how to use 2d transformations and animations to rotate views.

How do you rotate any view with that's a subclass of UIView?

like image 645
user717452 Avatar asked Dec 19 '25 09:12

user717452


1 Answers

You can use UIView animations and Transform methods. For rotating 90 degrees:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];

imageView.transform = CGAffineTransformMakeRotation(M_PI_2);

[UIView commitAnimations];
like image 163
Abdullah Umer Avatar answered Dec 21 '25 05:12

Abdullah Umer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!