CAkeyframeAnimation:
iOS提供了關(guān)鍵幀動(dòng)畫的支持。可以為層屬性指定key path來(lái)使其產(chǎn)生動(dòng)畫,這個(gè)數(shù)組的值保存了動(dòng)畫每個(gè)階段的值,同時(shí)還可以設(shè)置Keyframe的次數(shù)和時(shí)間函數(shù)。在動(dòng)畫運(yùn)行的時(shí)候,數(shù)組中的每個(gè)值就會(huì)被輪流進(jìn)行插值使用。Keyframe顧名思義就是關(guān)鍵點(diǎn)的frame,可以通過(guò)設(shè)定CALayer的始點(diǎn)、中間關(guān)鍵點(diǎn)、終點(diǎn)的frame,時(shí)間,動(dòng)畫會(huì)沿你設(shè)定的軌跡進(jìn)行移動(dòng)。
CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animation.duration = 0.7;
animation.removedOnCompletion = YES;
animation.fillMode = kCAFillModeForwards;
NSMutableArray *values = [NSMutableArray array];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 1.0)]];
[values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
animation.values = values;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
[self.layer addAnimation:animation forKey:@"key"];
定義以上動(dòng)畫,在tableView 加載cell的時(shí)候來(lái)進(jìn)行調(diào)用,就成功地為TableView定制一個(gè)動(dòng)畫。
https://github.com/kingsNow/tableViewAnimation