CABasicAnimation动画

使用CABasicAnimation动画:

   

 
   CALayer *znzLayer; = [[CALayer alloc]init];
//创建不断该表CALayer的transform属性动画
    CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
    CATransform3D fromValue = znzLayer.transform;
    //设置动画开始的属性值
    anim.fromValue = [NSValue valueWithCATransform3D:fromValue];
    //绕z轴旋转heading弧度的变换矩阵
    CATransform3D toValue = CATransform3DMakeRotation(headings, 0, 0, 1);
    //设置动画结束的属性
    anim.toValue = [NSValue valueWithCATransform3D:toValue];
    anim.duration = 0.5;//持续时间
    anim.removedOnCompletion = YES; //如果需要继续使用本动画可以不用设置该属性,默认为NO,
    //设置动画结束后anzLayer的变换矩阵
    znzLayer.transform = toValue;
    //为znzLayer添加动画
    [znzLayer addAnimation:anim forKey:nil];

    http://blog.csdn.net/yuhuangc/article/details/7594979,其他用法链接

 

 

posted @ 2015-07-27 19:03  sixindev  阅读(261)  评论(0编辑  收藏  举报