動畫在網(wǎng)上有很好的學(xué)習(xí)資料,這里列舉幾篇寫的比較好的。動畫的實(shí)現(xiàn)本質(zhì)上原理比較簡單蒿褂,不過需要的是細(xì)心,耐心卒暂,以及和UI的良好溝通啄栓。
UIImageView的動畫
比如開場動畫,經(jīng)常會用到也祠。比較簡單的是設(shè)置UIImageView
的動畫屬性昙楚。這個(gè)有點(diǎn)像視頻播放。
@property (nullable, nonatomic, copy) NSArray<UIImage *> *animationImages; // The array must contain UIImages. Setting hides the single image. default is nil
@property (nonatomic) NSTimeInterval animationDuration; // for one cycle of images. default is number of images * 1/30th of a second (i.e. 30 fps)
@property (nonatomic) NSInteger animationRepeatCount; // 0 means infinite (default is 0)
這樣做的缺點(diǎn)一般需要30~60
張png
圖片诈嘿,內(nèi)存占用比較大堪旧。有時(shí)候,干脆用視頻播放代替了奖亚。
iOS開發(fā)UI篇—iOS開發(fā)中三種簡單的動畫設(shè)置
UIView動畫
提供的block
形式的API
非常好用淳梦,可以滿足大多數(shù)的動畫需求。這個(gè)應(yīng)該成為平時(shí)實(shí)現(xiàn)動畫的主要方式昔字。
Core Animation
本質(zhì)上UIView
動畫都來自這里爆袍,直接用這個(gè),更靈活一點(diǎn)作郭。有必要的時(shí)候陨囊,可以考慮用這個(gè)來實(shí)現(xiàn)效果。