iOS開發(fā)- 啟動動畫(動態(tài)歡迎界面,非靜態(tài)Default)

本人ios初學者,為自己學習方便,復制各位大神的學習性文章放在自己簡書里,僅作為自己學習方便使用,如果作者疑此行為侵權,請隨時聯(lián)系本人刪除,如有共同學習者復制此文章,請注明原出處

最近在使用《青蔥日記》這款App,發(fā)現(xiàn)它的啟動界面做的很精美。不同我自己之前簡單的替換Default.png圖片。 它的動態(tài)效果做的不錯。于是乎,花了點時間,自己實現(xiàn)了這個功能。 其實也很簡單,具體效果如下

實現(xiàn)起來也不困難。因為我們知道,在應用啟動的時候,它會先執(zhí)行AppDelegate.m中的

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

執(zhí)行完之后,才會進入視圖。如果,我們在這個方法中加入一些動畫,那么就會在動畫執(zhí)行完之后再進入我們的rootview。這就是實現(xiàn)原理。 很簡單吧。下面直接給出實現(xiàn)這一效果的源碼,很簡單。不多說廢話(當然,實現(xiàn)方法很多。 我只是給出我自己的方法)

1.AppDelegate.h中聲明一個UIImageView

@property (strong, nonatomic) UIImageView *splashView;

2.AppDelegate.m實現(xiàn)相關功能

@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];

}

];

}

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 229,885評論 6 541
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,312評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 177,993評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,667評論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,410評論 6 411
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,778評論 1 328
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,775評論 3 446
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,955評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,521評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 41,266評論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,468評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,998評論 5 363
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 44,696評論 3 348
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,095評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,385評論 1 294
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,193評論 3 398
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,431評論 2 378

推薦閱讀更多精彩內(nèi)容