CABasicAnimation 3D旋转

        //动画为沿y轴旋转
        let animation = CABasicAnimation(keyPath: "transform.rotation.y")
        animation.fromValue = 0
        animation.toValue = Double.pi * 2
        animation.repeatCount = Float.infinity
        animation.duration = 2
        animatorView.layer.add(animation, forKey: "spin")
        
        //z轴td调大,防止旋转时被其他控件遮挡
        animatorView.layer.zPosition = 100
        
        //将view的tranform改为3d透视
        var transform = CATransform3DIdentity
        transform.m34 = 1.0 / 500.0//透视度
        animatorView.layer.transform = transform

猜你喜欢

转载自www.cnblogs.com/liuyongfa/p/10042391.html