2016年1月4日 星期一

iOS筆記:動畫圖片 UIImageView Animation

饒是我常常去翻文件結果還是漏看了這神奇的玩意(woot)
iOS2.0以後就有了怎麼一直都不知道


效果同等於android的 animation-list

開storyboard,拉一個image view到view controller上
按住control創一個IBOutlet叫做animationImageView
在viewDidLoad放上以下code,一進入view就會看到圖片在動
用animatedImageNamed: 會load所有step_img開頭的圖片,所以只要每張圖片檔名照順序存檔(step_img0, step_img1, step_img2, step_img3 ...)拉到專案就行了

self.animationImageView.image = [UIImage animatedImageNamed:@"step_img" duration:0.5f];
[self.animationImageView startAnimating];

(話說我買了 Appcoda出的中譯本,結果腦袋被夾了點了跟缺貨書籍一同出貨)


沒有留言:

張貼留言