Fade out Launch an iPhone 4-inch Screen Image

At startup, I lose my startup image to the application interface. To achieve this, I add a UIImageView with "Default.png" and animate its alpha just before makeKeyAndVisible .

Should Default.png always return a device-specific version of the startup image (or for a specific permission)? Or should I check the boundaries of the screen and the scale to choose the right one for the retina and not the retina and 3.5 against 4-inch screens?

I expected Default.png to behave the same as other image resources - use the @ 2x version with support (and the -568h version on iPhone 5). But my experiments in the simulator make me believe otherwise. When using a 4-inch simulator, a 3.5-inch image is used. This results in a display image that does not extend to the bottom of the screen. The screenshot below shows an intermediate transition animation.

enter image description here

Unfortunately, I do not have every device, so I could not confirm that this is just a simulator quirk.

In short, I want to be sure that the retina image is used on the mesh devices, and the 4-inch image is used on the 4-inch devices.

+4
source share
4 answers

The answer is that you will have to explicitly download the device-specific version of the image. This is a custom animation, and you cannot rely on Apple by default, regardless of download behavior, to achieve what you want.

First, make sure that you are configured correctly and that the correct default boot image is displayed on devices (don’t trust the simulator too much (otherwise I don’t even use such a simulator so badly)

And then, as previous commentators suggested, upload the presentation with your images.

Remember that the default image will be uploaded and displayed with the cocoa wireframe. All you can do is show the view after that, if you try to make some of the admittedly smart hacks with the Internet download enabled, you will find that they will always break.

If you need a full-screen image, animated or not on the iPhone 5, you need to explicitly download this image for the device that is for it.

+2
source

This is my code.

 - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ... [self.window makeKeyAndVisible]; [self _startLaunchAnimation]; return YES; } - (void)_launchAnimation { CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height; UIImageView *launchImageView = (UIImageView*)[self.window viewWithTag:1000]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.window cache:YES]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)]; [launchImageView setAlpha:0.0]; [launchImageView setFrame:CGRectMake(-60.0f, 0.0f, 320.0f, screenHeight)]; [UIView commitAnimations]; } - (void)_startLaunchAnimation { CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height; NSString *imageName = nil; if (screenHeight == 568.0f) { imageName = @"Default-568h.png"; } else { imageName = @"Default.png"; } UIImage *image = [UIImage imageNamed:imageName]; UIImageView *launchImageView = [[UIImageView alloc] initWithImage:image]; [launchImageView setTag:1000]; [self.window addSubview:launchImageView]; [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(_launchAnimation) userInfo:nil repeats:NO]; } 
+6
source

For the record, this is my version of @agassi_yzh's solution:

 //fade from the launch image to the interface CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; NSString *imageFile = (screenHeight == 568.0f) ? @"Default-568h.png" : @"Default.png"; UIImageView *splash = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageFile]]; [self.window.rootViewController.view addSubview:splash]; [UIView animateWithDuration:0.5 animations:^{ splash.alpha = 0; } completion:^(BOOL finished) { [splash removeFromSuperview]; } ]; //display the main window [self.window makeKeyAndVisible]; 
+4
source

Yes, you provide Default.png and Default@2x.png , you even need to provide Default 568h@2x.png for the iPhone 5 4 screen.

Your application will use a standard grid, retina or large retina according to the device, but note that Apple prevents the use of the default launch image as any animation sequence.

The trick you can use is to add the image as the initial screen of the application when it starts and immediately disappears, it will give the user the impression that the launch image disappears even if the launch image is gone and your perception of the image captures.

See the “Launch” section in the “Apple Custom Icon and Image Creation User Guide” :

Deliver a startup image to enhance the user interface.

Avoid using the launch image as an opportunity to provide:

• “App logon experience”, such as a splash screen

• Window "About the program"

• Branding elements, if they are not a static part of your applications, primarily the screen. Since users can often switch between applications, you should make every effort to reduce startup time to a minimum, and you should create a startup image that reduces experience, rather than paying attention to it.

0
source

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


All Articles