本人ios初學者膛腐,為自己學習方便,復制各位大神的學習性文章放在自己簡書里执解,僅作為自己學習方便使用寞肖,如果作者疑此行為侵權,請隨時聯系本人刪除衰腌,如有共同學習者復制此文章新蟆,請注明原出處
最近在使用《青蔥日記》這款App,發(fā)現它的啟動界面做的很精美右蕊。不同我自己之前簡單的替換Default.png圖片琼稻。 它的動態(tài)效果做的不錯。于是乎,花了點時間饶囚,自己實現了這個功能帕翻。 其實也很簡單,具體效果如下
實現起來也不困難萝风。因為我們知道嘀掸,在應用啟動的時候,它會先執(zhí)行AppDelegate.m中的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
執(zhí)行完之后,才會進入視圖。如果闹丐,我們在這個方法中加入一些動畫横殴,那么就會在動畫執(zhí)行完之后再進入我們的rootview。這就是實現原理卿拴。 很簡單吧衫仑。下面直接給出實現這一效果的源碼,很簡單。不多說廢話(當然,實現方法很多堕花。 我只是給出我自己的方法)
1.AppDelegate.h中聲明一個UIImageView
@property (strong, nonatomic) UIImageView *splashView;
2.AppDelegate.m實現相關功能
@synthesizesplashView;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(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 bringSubviewToFront:splashView];
[self performSelector:@selector(scale_1) withObject:nil afterDelay:0.0f];
[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];
returnYES;
}
-(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:^
{
// 執(zhí)行的動畫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)
{
// 完成后執(zhí)行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)
{
// 完成后執(zhí)行code
[NSThread sleepForTimeInterval:1.0f];
[splashView removeFromSuperview];
}
];
}