-
(void)animation1 {
[self moveAnchorPoint:CGPointMake(0.5, 0.5) With:self.logoImageView.layer];
POPSpringAnimation *anim = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
anim.fromValue = [NSValue valueWithCGSize:CGSizeMake(0.0, 0.0)];
anim.toValue = [NSValue valueWithCGSize:CGSizeMake(1.0, 1.0)];
// 速度 可设范围0-20,默认12,值越大速度越快,结束的越快
anim.springSpeed = 8.0f;
// 振幅 可设范围0-20,默认4,值越大振动幅度越大
anim.springBounciness = 5.0f;
// 拉力 拉力越大,动画的速度越快,结束的越快。 接下来的三个值一般不用设置,可以分别放开注释查看效果
// anim.dynamicsTension = 250;
// 摩擦力 摩擦力越大,动画的速度越慢,振动的幅度越小。
// anim.dynamicsFriction = 100.0;
// 质量 质量越大,动画的速度越慢,振动的幅度越大,结束的越慢
anim.dynamicsMass = 10;
anim.beginTime = CACurrentMediaTime() + 1.0f;
// 重复
// anim.repeatForever = YES;
// 3. 添加到view上
[self.logoImageView.layer pop_addAnimation:anim forKey:@"ScaleXY"];
} -
(void)moveAnchorPoint:(CGPoint)point With:(CALayer *)originLayer {
CGPoint oldOrigin = originLayer.frame.origin;
originLayer.anchorPoint = point;
CGPoint newOrigin = originLayer.frame.origin;CGPoint translation = NSMakePoint(newOrigin.x - oldOrigin.x, newOrigin.y - oldOrigin.y);
NSRect frame = originLayer.frame;
[originLayer setFrame:frame];
frame.origin = NSMakePoint(originLayer.frame.origin.x - translation.x, originLayer.frame.origin.y - translation.y);
[originLayer setFrame:frame];
}
网友评论