Ipad / Iphone - rotation in UIView with images all

How to rotate a UIView with full content. I'm having trouble rotating a UIView. Can someone help me ??? please give me some step-by-step example.

+3
source share
2 answers

This is pretty easy:

myUIView.transform = CGAffineTransformMakeRotation(M_PI * 0.5); 

This will turn the whole thing 90 degrees to the right, the contents and all. The argument for CGAffineTransformMakeRotation is in radians ...

+3
source

. , , , . UIView, . . .

, ...

- (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.

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!!!!
+1

Source: https://habr.com/ru/post/1778898/


All Articles