iOS开发程序员

Animation_SpringAnimation

2017-11-23  本文已影响4人  iOS小童

Welcome to my blog. Thanks.

Dome: github地址

昨天整理了BasicAnimation,昨晚对SpringAnimation也进行了梳理。说白了,它的父类也是BasicAnimation,也增加了UIView 实例方法的应用。明天将会整理CATransition动画使用方法和应用实例。

SpringAnimation

1、

mass:

质量,影响图层运动时的弹簧惯性,质量越大,弹簧拉伸和压缩的幅度越大

动画的速度变慢,并且波动幅度变大

2、

stiffness:

刚度系数(劲度系数/弹性系数),刚度系数越大,形变产生的力就越大,运动越快

3、

damping:

阻尼系数,阻止弹簧伸缩的系数,阻尼系数越大,停止越快

4、

initialVelocity:

初始速率,动画视图的初始速度大小

速率为正数时,速度方向与运动方向一致,速率为负数时,速度方向与运动方向相反

5、

CASpringAnimation * springAnimation = [CASpringAnimation animationWithKeyPath:@"position"];
springAnimation.damping = damping;
springAnimation.stiffness = stiffness;
springAnimation.mass = mass;
springAnimation.initialVelocity = initialVelocity;
springAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(self.redView.layer.position.x, self.redView.layer.position.y + 200)];
springAnimation.duration = springAnimation.settlingDuration;
[self.redView.layer addAnimation:springAnimation forKey:springAnimation.keyPath];

6、

 [UIView animateWithDuration:5 delay:0 usingSpringWithDamping:0.3 initialSpringVelocity:10 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
        CGPoint point =self.redView.center;
        point.y += 150;
        [self.redView setCenter:point];
    } completion:^(BOOL finished) {
        [self.redView setCenter:CGPointMake(250 + 49, 250 + 49)];
        [self.redView setBackgroundColor:[UIColor redColor]];
    }];
}     
      duration: 动画时长
      delay: 动画延迟
      damping: 弹簧效果
      springVelocity: 初始速度
      options: 过度效果
上一篇 下一篇

猜你喜欢

热点阅读