Reprinted, please indicate the source, retain the original post address and the author's signature.
URL: http://blog.csdn.net/ysy441088327/article/details/8852304
Author: Xu Shu
Introduction:
Excellent instancesThis is a new topic for bloggers. This topic mainly introduces some examples that are worth practicing in IOS apps.
You are welcome to repost and spread it, but please keep the original source because I may update and correct it at any time.
I hope that developers who read the best examples can benefit from this and use these skills skillfully.
So as you guys, please try to leave your suggestions and opinions after reading this article. This is one of the main ways for me to continuously improve the article.
I can hardly predict the number of chapters in the essence instance. However, as long as it is worth writing, I will write it out so that everyone can learn and grow together!
There are a lot of nonsense in the beginning, and the following will start to enter the text:
What is the excessive App-initiated illustration customization?
We all know that when an app is started, it will show an app startup illustration to ensure the waiting experience of APP loading, so that users can enjoy the beautiful illustration, the app is truly trying to load related resources,
The app automatically calls the main function, followed by didfinishlaunchingwitexceptions.
When makekeyandvisible is executed in the uiwindow, this start illustration disappears automatically, but it disappears instantly.
The so-calledOver-CustomizationIt is to make the start illustration disappear more friendly (rather than instantly disappear), I believe many of the mainstream app products have seen this effect.
This implementation method is the focus of this article!
What is the program principle?
The program sometimes feels a little magical. It is always mysterious when you don't know the principle!
We can set the app startup illustration through the Project Settings-targets-Summary-launch images.
But the illustrationPointerWe cannot get it. (If we get it, this article is estimated to be very short, not even .)
What should we do? We must have this pointer before we can implement a user-defined excess, such as the disappearance of, the effect of turning a page of books, and so on.
For our purposes, we only have ourselvesAllocOneUiimageviewThe loaded image is the image we started the illustration.
However, make sure that: What is the starting illustration, and what should our own alloc uiimageview look like? Otherwise, this experience will be compromised. What do you say?
And thisUiimageviewWhat should we do?AddsubviewWhere is the technical difficulty of this instance.
What is the answer?
Yesuiwindow! But notKeywindowWe need ourselves.AllocOfUiwindow! But itsWindowlevelAspect RatioKeywindowLevel 1!
That is to say, in order to make the uiimageview show smoothly and make sure it looks the same as starting the illustration, we need a container of uiwindow. The Code is as follows:
UiwindowIs a magic class, when youAllocAndWindowlevelSet RatioKeywindowOfLevelWhen it is high, no additional execution is required.MakekeyandvisibleOrAddsubviewTo make thisUiwindowDisplayed.
However, this uiwindow'sHiddenThe default attribute is yes, so we need to set hidden to no! Make the uiwindow display.
Next we willUiimageviewCall addsubview to access the uiwindow.
Note the following when alloc uiimageview:
Do not passImagenamedTo obtainUiimageEveryone should knowImagenamedIt will automatically cache the loaded image resources. If you call an image with the same name next time, it will be obtained directly from the memory.UiimageviewIt is used only once. It is no longer necessary to use it again after the illustration is hidden.
So what is the correct way to get it?
ToAbsolute pathTo obtain the image resource, as shown below:
ImagewithcontentsoffileIt is in line with our current needs to use image resources, because it will be automatically cleared after use (ARC)
At this point, ourStartup illustration of disguised versionDeployment completed.
When will it be called?
Run the code in viewwillappear In the first started viewcontroller. In case of exceptions, the started Illustration will always be displayed.
But we don't want to keep displaying it all the time. It should almost disappear, but it is more friendly when it disappears!
Because we already have a pointer to the uiimageview, We can freely control the way this uiimageview disappears.
The purpose of this article is as follows:
App startup illustration customization too much
The blogger has encapsulated a class for this instance function to facilitate calls! It has been uploaded to GitHub. You are welcome to use it and provide feedback.
Its name is syappstart.
The syappstart API is very simple,
Provides a set of default display and hide Methods
The core of hidewithcustomblock is to customize more ways to hide illustrations.
Hope someone can customize the hidden code of pull request!
TIPS:
1. How to display the startup illustration in full screen (hiding the status bar )?
Hook it up!
2. How can I restore the display of the status bar immediately after the display is complete?
Summary:
The blogger himself has encapsulated this function and basically does not need to care about the implementation of the core function. Why bother to elaborate on the principle?
Because this function is implemented by using uiwindow, or we want to better control the top status bar, we can understandUiwindowFirst!
If you have any questions after reading this article, make sure you do not want to register a csdn account. You can use Weibo to send a private message to me. This is the main way for me to continuously improve the content of this article. Thank you!