1.pop
1> facebook出品的动画框架,有cocapod直接安装,没装的话,直接下载pop.framework,添加该框架才可以用
2> 动画能作用在任何对象上
3> 能监听到动画的中间值
2.Core Animation
1> 苹果官方的动画框架
2> 动画只能作用在CALayer上
3> 无法监听到动画的中间值
// 创建动画
// PropertyNamed可以是给控件的属性,也可以是给控件的layer赋值
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPViewFrame];
// POPSpringAnimation *anim1 = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
// 设置动画属性
anim.fromValue = [NSValue valueWithCGRect:CGRectMake(buttonX, buttonY - XMGScreenH, buttonW, buttonH)];
anim.toValue = [NSValue valueWithCGRect:CGRectMake(buttonX, buttonY, buttonW, buttonH)];
// 动画弹性速度
anim.springSpeed = XMGSpringFactor;
// 动画弹性阻尼系数
anim.springBounciness = XMGSpringFactor;
// CACurrentMediaTime()获得的是当前时间
// 动画开始时间
anim.beginTime = CACurrentMediaTime() + 2.0;
// 给控件增加动画
[button pop_addAnimation:anim forKey:nil];
// 给控件的layer增加动画
// [button.layer pop_addAnimation:anim forKey:nil];
// POPBasicAnimation动画
POPBasicAnimation *anim = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerPositionY];
anim.toValue = @(self.sloganView.layer.position.y + XMGScreenH);
// CACurrentMediaTime()获得的是当前时间
anim.beginTime = CACurrentMediaTime() + 1.0;