骚年就知道你会进来!!!哈哈哈
直入主题,以免被打!
效果:
代码:
let doorLayer = CALayer()
doorLayer.frame = CGRectMake(0, 0, 120, 302)
doorLayer.position = CGPointMake(self.view.bounds.size.width / 2+60, self.view.bounds.size.height / 2)
doorLayer.anchorPoint = CGPointMake(1, 0.5)
doorLayer.contents = UIImage.init(named: "door")?.CGImage
self.view.layer.addSublayer(doorLayer)
var perspective = CATransform3DIdentity;
perspective.m34 = -1.0 / 500.0;
self.view.layer.sublayerTransform = perspective;
let animation = CABasicAnimation();
animation.keyPath = "transform.rotation.y";
animation.toValue = M_PI_2;
animation.duration = 10.0;
animation.repeatDuration = Double.infinity;
animation.autoreverses = true;
doorLayer.addAnimation(animation, forKey: nil)
啥都不讲了