有关动画的code(2中 以后慢慢添加)

来源:互联网 发布:布艺沙发床价格淘宝 编辑:程序博客网 时间:2024/05/28 05:15

    


    //CABasicAnimation

    [blackView.layeraddAnimation:[selfopacityForever_Animation:3.0]forKey:@"key"];

    //UIView Animation

    [self animationRevealFromBotton:100];



    transform.scale.x 宽的比例转换

    transform.scale.y 高的比例转换

    transform.rotation.z 平面圆的旋转

    opacity 透明度

    margin 在视图中展示内容的大小

    zPosition 屏幕上层次的前后顺序

    backgroundColor 背景颜色

    cornerRadius 圆角

    borderWidth 边的宽度

    bounds layer的边界矩阵, frame类似contents内容, 例如:图片的变化 contentsRect 内容可使用layer的大小frame 视图的frame矩阵hidden隐藏状态 mask 遮挡背景和内容显示的透明度 masksToBounds决定子layer是否从layer的边界中剪除position layer在其父layer中对应的位置shadowColor阴影颜色shadowOffset 阴影偏移量shadowOpacity阴影透明度shadowRadius 阴影圆角


- (CABasicAnimation *)opacityForever_Animation:(float)time

//永久闪烁的动画:渐变 

{

    //参数必须是layer的属性“属性”

    CABasicAnimation *animation=[CABasicAnimationanimationWithKeyPath:@"backgroundColor"];


//属性的值的变换

//    animation.fromValue=[NSNumber numberWithFloat:1.0];

//    animation.toValue=[NSNumber numberWithFloat:3.0];

//位置变换  点对点

    animation.fromValue = [NSValuevalueWithCGPoint:CGPointMake(125,125)];

    animation.toValue = [NSValuevalueWithCGPoint:CGPointMake(self.view.frame.size.width /2, self.view.frame.size.height /2)];

    

    animation.autoreverses=YES;

    //持续时间

    animation.duration=time;

  //重复次数

    animation.repeatCount=FLT_MAX;

    animation.removedOnCompletion=NO;

    

    animation.fillMode=kCAFillModeForwards;

    return animation;

}


- (void)animationRevealFromBotton:(float)duration

{

    [UIView animateWithDuration:durationanimations:^{

        blackView.transform =CGAffineTransformMakeScale(0.001,0.001);

        CABasicAnimation *animation = [CABasicAnimationanimationWithKeyPath:@"transform"];

        animation.toValue = [NSValuevalueWithCATransform3D:CATransform3DMakeRotation(M_PI,0.70, 0.40,0.80)];

        animation.duration = 0.45;

        animation.repeatCount = FLT_MAX;

        [blackView.layeraddAnimation:animation forKey:nil];

    } completion:^(BOOL finished) {

        [UIView animateWithDuration:durationanimations:^{

            blackView.transform =CGAffineTransformMakeScale(1.0,1.0);

        }];

    }];

}


0 0