Launchimage disappears immediately after the app is initialized and displays the app's interface, but sometimes we don't want it to disappear so quickly (for example, some people want to have a transition effect some people want to wait for certain settings or data to disappear after loading), which is also very simple, We just have to show the launchimage again and the top is OK.
But we've configured so many launchimage for different screen resolutions how do we get launchimage for the current screen resolution?
The common approach is to add all launchimage to the project and name it according to the screen resolution (640_960.png 640_1136.png ...) and then use the code in the program to stitch up the corresponding file name and reference
But this method is relatively primitive and in case the apple out of some other resolution of the device or the start diagram changes when the need to manually modify the project configuration is not very good and need more than a share of resources (the app's capacity has become larger)
And Stackflow on the Cherpak Evgeny share a better way to directly read the settings in NSBundle to get the current applicable launchimage
I've written a demo code with the diagram above as an example:
Cgsize viewsize = self.window.bounds.size;
NSString *vieworientation = @ "Portrait"; Horizontal screen please set to @ "Landscape"
NSString *launchimage = nil;
nsarray* imagesdict = [[[NSBundle Mainbundle] infodictionary] valueforkey:@ "Uilaunchimages"];
For (nsdictionary* dict in imagesdict)
{
Cgsize imageSize = cgsizefromstring (dict[@ "uilaunchimagesize"]);
if (Cgsizeequaltosize (ImageSize, viewsize) && [vieworientation isequaltostring:dict[@] Uilaunchimageorientation "])
{
Launchimage = dict[@ "Uilaunchimagename"];
}
}
Uiimageview *launchview = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@ "Launchimage"];
Launchview.frame = Self.window.bounds;
Launchview.contentmode = Uiviewcontentmodescaleaspectfill;
[Self.window Addsubview:launchview];
[UIView animatewithduration:1.0f
delay:0.5f
Options:uiviewanimationoptionbeginfromcurrentstate
animations:^{
Launchview.alpha = 0.0f;
LaunchView.layer.transform = Catransform3dscale (catransform3didentity, 1.2, 1.2, 1);
}
completion:^ (BOOL finished) {
[Launchview Removefromsuperview];
}];
IOS Settings Launchimage Animations