3D旋转UIView

来源:互联网 发布:网络赚钱之道 编辑:程序博客网 时间:2024/04/29 16:10

double radians(double degrees) {

    return ( degrees * 3.14159265 ) / 180.0;

}

  

//这里的旋转与anchor有关系,不同的anchor有不同的旋转轴

  CABasicAnimation *animation = [ CABasicAnimation

                                   animationWithKeyPath: @"transform" ];

    animation.toValue =[ NSValue valueWithCATransform3D: CATransform3DMakeRotation(radians(90.0), 0, 1, 0) ];

    animation.cumulative=YES;

    animation.duration = 1.5;

    animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];

    [animation setFillMode:kCAFillModeForwards];  

    [animation setRemovedOnCompletion:NO]; 

    [testView.layer addAnimation: animation forKey: @"animation" ];

原创粉丝点击