我尝试通过更改CATransform3DMakeTranslation
将UIView移近相机。我导入了QuartzCore但没有任何反应
我的代码正在关注
let pan = UIPanGestureRecognizer(target: self, action: "pan:")
dummyView.addGestureRecognizer(pan)
func pan(gesture:UIPanGestureRecognizer) {
switch gesture.state {
case .Changed: fallthrough
case .Ended:
let translation = gesture.translationInView(dummyView)
var transform = CATransform3DMakeTranslation(0, 0, translation.x)
dummyView.layer.transform = transform
default: break
}
}
我做错了什么?
答案 0 :(得分:0)
您需要添加子图层转换以向图层添加透视。
var initialTransform = self.layer.transform
initialTransform.m34 = 1.0 / -500 //adjust this value for your needs
self.layer.sublayerTransform = initialTransform
(假设self.layer
是dummyView.layer
)