IOS screen animation

In my application, I want the screensaver to be animated. I am using the following code, but the animation does not work.

UIImageView *splashScreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"Default.png"]];
[self.window.rootViewController.view addSubview: splashScreen];

[self.window makeKeyAndVisible];

NSLog(@"begin splash");
[UIView animateWithDuration: 0.2
                      delay: 0.5
                    options: UIViewAnimationOptionCurveEaseOut
                animations: ^{splashScreen.alpha = 0.0;
                }
                completion: ^ (BOOL finished) {
                    [splashScreen removeFromSuperview];
                    NSLog(@"end splash");
                }
];
+3
source share
2 answers

You cannot animate the splash image, but you can wait for the application to launch and add your own animation view.

+6
source

you cannot help but use some of the tricks that he will achieve

Open the AppDelegate.m application and add the following code to your application. FIFF file or didFinishLaunchingWithOptions application:

//1. add the image to the front of the view...
UIImageView *splashImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[splashImage setImage: [UIImage imageNamed:@"Default"]];
[self.window addSubview:splashImage];
[self.window bringSubviewToFront:splashImage];

//2. set an anchor point on the image view so it opens from the left
splashImage.layer.anchorPoint = CGPointMake(0, 0.5);

//reset the image view frame
splashImage.frame = CGRectMake(0, 0, 320, 480);

//3. animate the open
[UIView animateWithDuration:1.0
                      delay:0.6
                    options:(UIViewAnimationCurveEaseOut)
                 animations:^{

                     splashImage.layer.transform = CATransform3DRotate(CATransform3DIdentity, -M_PI_2, 0, 1, 0);
                 } completion:^(BOOL finished){

                     //remove that imageview from the view
                     [splashImage removeFromSuperview];
                 }];

download sample application

animated-splash-screen-default-png

+6
source

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


All Articles