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

本人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];

}

];

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
  • 序言:七十年代末文狱,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子缘挽,更是在濱河造成了極大的恐慌瞄崇,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,000評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件壕曼,死亡現場離奇詭異苏研,居然都是意外死亡,警方通過查閱死者的電腦和手機腮郊,發(fā)現死者居然都...
    沈念sama閱讀 94,745評論 3 399
  • 文/潘曉璐 我一進店門摹蘑,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人轧飞,你說我怎么就攤上這事衅鹿∪鲎伲” “怎么了?”我有些...
    開封第一講書人閱讀 168,561評論 0 360
  • 文/不壞的土叔 我叫張陵大渤,是天一觀的道長制妄。 經常有香客問我,道長泵三,這世上最難降的妖魔是什么耕捞? 我笑而不...
    開封第一講書人閱讀 59,782評論 1 298
  • 正文 為了忘掉前任,我火速辦了婚禮切黔,結果婚禮上砸脊,老公的妹妹穿的比我還像新娘。我一直安慰自己纬霞,他們只是感情好,可當我...
    茶點故事閱讀 68,798評論 6 397
  • 文/花漫 我一把揭開白布驱显。 她就那樣靜靜地躺著诗芜,像睡著了一般。 火紅的嫁衣襯著肌膚如雪埃疫。 梳的紋絲不亂的頭發(fā)上伏恐,一...
    開封第一講書人閱讀 52,394評論 1 310
  • 那天,我揣著相機與錄音栓霜,去河邊找鬼翠桦。 笑死,一個胖子當著我的面吹牛胳蛮,可吹牛的內容都是我干的销凑。 我是一名探鬼主播,決...
    沈念sama閱讀 40,952評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼仅炊,長吁一口氣:“原來是場噩夢啊……” “哼斗幼!你這毒婦竟也來了?” 一聲冷哼從身側響起抚垄,我...
    開封第一講書人閱讀 39,852評論 0 276
  • 序言:老撾萬榮一對情侶失蹤蜕窿,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后呆馁,有當地人在樹林里發(fā)現了一具尸體桐经,經...
    沈念sama閱讀 46,409評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,483評論 3 341
  • 正文 我和宋清朗相戀三年浙滤,在試婚紗的時候發(fā)現自己被綠了阴挣。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,615評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡瓷叫,死狀恐怖屯吊,靈堂內的尸體忽然破棺而出送巡,到底是詐尸還是另有隱情,我是刑警寧澤盒卸,帶...
    沈念sama閱讀 36,303評論 5 350
  • 正文 年R本政府宣布骗爆,位于F島的核電站,受9級特大地震影響蔽介,放射性物質發(fā)生泄漏摘投。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,979評論 3 334
  • 文/蒙蒙 一虹蓄、第九天 我趴在偏房一處隱蔽的房頂上張望犀呼。 院中可真熱鬧,春花似錦薇组、人聲如沸外臂。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,470評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽宋光。三九已至,卻和暖如春炭菌,著一層夾襖步出監(jiān)牢的瞬間罪佳,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,571評論 1 272
  • 我被黑心中介騙來泰國打工黑低, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留赘艳,地道東北人。 一個月前我還...
    沈念sama閱讀 49,041評論 3 377
  • 正文 我出身青樓克握,卻偏偏與公主長得像蕾管,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子玛荞,可洞房花燭夜當晚...
    茶點故事閱讀 45,630評論 2 359

推薦閱讀更多精彩內容

  • 1娇掏、設置UILabel行間距 NSMutableAttributedString* attrString = [[...
    FF_911閱讀 1,383評論 0 3
  • 1、設置UILabel行間距 NSMutableAttributedString* attrString = [[...
    十年一品溫如言1008閱讀 1,663評論 0 3
  • //設置尺寸為屏幕尺寸的時候self.window = [[UIWindow alloc] initWithFra...
    LuckTime閱讀 819評論 0 0
  • 轉自:http://www.code4app.com/blog-866962-1317.html1勋眯、設置UILab...
    MMOTE閱讀 1,626評論 1 1
  • 所謂感覺婴梧,沒有那么難理解,身材外貌是表客蹋,性格內涵是里塞蹭,一言一行體現素養(yǎng),穿衣打扮彰顯風格讶坯,沒有對與錯的人番电,只有合不...
    綠野V仙蹤閱讀 228評論 0 0