IOS development-enable animation (Dynamic welcome interface, non-static Default)

Source: Internet
Author: User

Recently I used the "green onion Diary" App and found that its startup interface is very exquisite.

In other words, I simply replace the default.png image. Its dynamic effect is good.

It took some time to implement this function. It is actually quite simple. The specific effect is as follows:




It is not difficult to implement. Because we know that when the application is started, it will first execute

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

After execution, the view is displayed. If we add some animations to this method, we will enter our rootview after the animation is executed. This is the implementation principle. It's easy.


The source code to achieve this effect is provided below, which is very simple. Not much nonsense (of course, there are many implementation methods. I just gave my own method)


1. Declare a UIImageView in AppDelegate. h.

@ Property (strong, nonatomic) UIImageView * splashView;

2. AppDelegate. m to implement related functions

@ Synthesize splashView;-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {// Override point for customization after application launch. [self. window makeKeyAndVisible]; splashView = [[UIImageView alloc] initWithFrame: CGRectMake (0, 0,320,568)]; [splashView setImage: [UIImage imageNamed: @ "back _"]; [self. window addSubview: splashView]; [self. window layout: splashView]; [self defined mselector: @ selector (scale_1) withObject: nil afterDelay: 0.0f]; [self defined mselector: @ selector (scale_2) withObject: nil limit: 0.5f]; [self defined mselector: @ selector (scale_3) withObject: nil afterDelay: 1.0f]; [self defined mselector: @ selector (scale_4) withObject: nil afterDelay: 1.5f]; [self defined mselector: @ selector (scale_5) withObject: nil afterDelay: 2.0f]; [self defined mselector: @ selector (showWord) withObject: nil afterDelay: 2.5f]; return YES;}-(void) scale_1 {UIImageView * round_1 = [[UIImageView alloc] initWithFrame: CGRectMake (100,240, 15, 15)]; round_1.image = [UIImage imageNamed: @ "round _"]; [splashView addSubview: round_1]; [self setAnimation: round_1];}-(void) scale_2 {UIImageView * round_2 = [[UIImageView alloc] initWithFrame: CGRectMake (105,210, 20, 20)]; round_2.image = [UIImage imageNamed: @ "round _"]; [splashView addSubview: round_2]; [self setAnimation: round_2];}-(void) scale_3 {UIImageView * round_3 = [[UIImageView alloc] initWithFrame: CGRectMake (125,170, 30, 30)]; round_3.image = [UIImage imageNamed: @ "round _"]; [splashView addSubview: round_3]; [self setAnimation: round_3];}-(void) scale_4 {UIImageView * round_4 = [[UIImageView alloc] initWithFrame: CGRectMake (160,135, 40, 40)]; round_4.image = [UIImage imageNamed: @ "round _"]; [splashView addSubview: round_4]; [self setAnimation: round_4];}-(void) scale_5 {UIImageView * heart_1 = [[UIImageView alloc] initWithFrame: CGRectMake (130,180,100,100)]; Parameters = [UIImage imageNamed: @ "heart _"]; [splashView addSubview: heart_1]; [self setAnimation: heart_1];}-(void) setAnimation :( UIImageView *) nowView {[UIView animateWithDuration: 0.6f delay: 0.0f options: UIViewAnimationOptionCurveLinear animations: ^ {// executed animation code [nowView setFrame: CGRectMake (nowView. frame. origin. x-nowView. frame. size. width * 0.1, nowView. frame. origin. y-nowView.frame.size.height * 0.1, nowView. frame. size. width * 1.2, nowView. frame. size. height * 1.2)];} completion: ^ (BOOL finished) {// After completion, run the code [nowView removeFromSuperview] ;}];}-(void) showWord {UIImageView * word _ = [[UIImageView alloc] initWithFrame: CGRectMake (75,440,170, 29)]; word _. image = [UIImage imageNamed: @ "word _"]; [splashView addSubview: word _]; word _. alpha = 0.0; [UIView animateWithDuration: 1.0f delay: 0.0f options: UIViewAnimationOptionCurveLinear animations: ^ {word _. alpha = 1.0;} completion: ^ (BOOL finished) {// After completion, run the code [NSThread sleepForTimeInterval: 1.0f]; [splashView removeFromSuperview];}


On the way to learning, I will share with you.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.