How rotate UIView with full of contents. I am getting problem in rotation of UIViews. Can any one help me out??? please g开发者_开发百科ive me some like with step by step example.
It's pretty easy:
myUIView.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
That will turn the whole thing 90 degrees to the right, contents and all. The argument to CGAffineTransformMakeRotation is in radians...
Hey thanks a lot for your response. Stuff which are related to rotation are solved but still i have few problems in Landscape mode i am using this code to animate Two UIViews but in Landscape Mode One view is not appearing i want an ideal solution for this.
Rotation Code which i am currently using...
- (void)viewDidLoad
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (void)didRotate:(NSNotification *)notification {
UIDeviceOrientation orientation = [[notification object] orientation];
if (orientation == UIDeviceOrientationLandscapeLeft)
{
CGRect contentRect = CGRectMake(0,0, 1024, 748);
self.view.bounds = contentRect;
[self.view setTransform:CGAffineTransformMakeRotation(M_PI / 2.0)];
}
else if (orientation == UIDeviceOrientationLandscapeRight)
{
CGRect contentRect = CGRectMake(0,0, 1024, 748);
self.view.bounds = contentRect;
[self.view setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)];
}
else if (orientation == UIDeviceOrientationPortraitUpsideDown)
{
CGRect contentRect = CGRectMake(0,0, 768, 1024);
self.view.bounds = contentRect;
[self.view setTransform:CGAffineTransformMakeRotation(M_PI)];
}
else if (orientation == UIDeviceOrientationPortrait) {
CGRect contentRect = CGRectMake(0,0, 768, 1024);
self.view.bounds = contentRect;
[self.view setTransform:CGAffineTransformMakeRotation(0.0)];
}
}
UIView amination code.
self.loginView.hidden=NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
self.AcTypeView.transform=CGAffineTransformMakeTranslation(0, 493);
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
self.loginView.transform=CGAffineTransformMakeTranslation(0, -700);
[UIView commitAnimations];
Thanks!!!!
精彩评论