</pre><p></p><p style="border-width:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:8px; list-style:none; text-indent:2em; color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px">之前的App启动动画是简单的替换Default.png图片,现在给大家推荐下面的App启动动画,</p><p style="border-width:0px; padding-top:0px; padding-bottom:0px; margin-top:0px; margin-bottom:8px; list-style:none; text-indent:2em; color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px"><span style="text-indent:2em">其过程也相当简单</span><span style="text-indent:2em">,具体效果如下</span></p><p><img src="http://www.2cto.com/uploadfile/Collfiles/20140212/2014021209190328.gif" alt="" /></p><p></p><p><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px">在应用启动的时候,它会先执行AppDelegate.m中的</span></p><p><span style="color:rgb(51,51,51); font-family:宋体; font-size:14px; line-height:28px; text-indent:28px"></span></p><pre name="code" class="html">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
执行完之后,才会进入视图。如果,我们在这个方法中加入一些动画,那么就会在动画执行完之后再进入我们的rootview。
下面直接给出实现这一效果的源码:
<span style="font-size:32px;color:#ff0000;">1.AppDelegate.h中声明一个UIImageView</span>
@property (strong, nonatomic) UIImageView *splashView;
<span style="font-size:32px;color:#ff0000;">2.AppDelegate.m实现相关功能</span>
@synthesize splashView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
//设置 <span style="font-family: 宋体;"> splashView</span>
splashView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 568)];
[splashView setImage:[UIImage imageNamed:@"back_"]];
[self.window addSubview:splashView];
//将显示在最前面只需要调用其父视图的bringSubviewToFront 方法
[self.window bringSubviewToFront:splashView];
//设置加载在上的图片延迟加载
[self performSelector:@selector(scale_1) withObject:nil afterDelay:0.0f];</span><span style="font-family: 宋体; line-height: 28px;">//第一个圆</span><span style="font-family:宋体;line-height: 28px;">
[self performSelector:@selector(scale_2) withObject:nil afterDelay:0.5f];//第二个园
[self performSelector:@selector(scale_3) withObject:nil afterDelay:1.0f];//第三个圆
[self performSelector:@selector(scale_4) withObject:nil afterDelay:1.5f];//第四个圆
[self performSelector:@selector(scale_5) withObject:nil afterDelay:2.0f];//心
[self performSelector:@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)]; heart_1.image = [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:^ {
// 执行的动画code
[nowView setFrame:CGRectMake(nowView.frame.origin.x - nowView.frame.size.width * 0.1,
}
completion:^(BOOL finished)
{
// 完成后执行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)
{
// 完成后执行code
[NSThread sleepForTimeInterval:1.0f];
[splashView removeFromSuperview];
}
];
借鉴: 红黑联盟