演示如何编写自己的动画引擎:CHAnimation
jopen
10年前
CHAnimation 用来演示如何编写自己的动画引擎,灵感来自于 非死book Pop,只需 600 行的 Objective-C 代码。
#import "CHAnimation.h" CHAnimation *animation = [CHAnimation new]; animation.duration = 0.4; animation.writeBlock = ^(id obj, id value) { button.center = [value CGPointValue]; }; animation.fromValue = [NSValue valueWithCGPoint:CGPointMake(70, 70)]; animation.toValue = [NSValue valueWithCGPoint:CGPointMake(170, 170)]; [button ch_addAnimation:animation forKey:@"animation"];