xcode Swift 3 中的多个 CGAffineTransforms
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38252402/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiple CGAffineTransforms in Swift 3
提问by user2428168
In Swift 2, we could do this to get a rotation and a stretch:
在 Swift 2 中,我们可以这样做以获得旋转和拉伸:
let rotate = CGAffineTransformMakeRotation(1)
let stretchAndRotate = CGAffineTransformScale(rotate, 0.8, 0.8)
label.transform = stretchAndRotate
In Swift 3, CGAffineTransformScale has become CGAffineTransform and no longer accepts a rotation.
在 Swift 3 中, CGAffineTransformScale 变成了 CGAffineTransform 并且不再接受旋转。
What is the simplest way to apply a stretch and rotation to an object now?
现在对对象应用拉伸和旋转的最简单方法是什么?
Thanks,
谢谢,
Rob
抢
回答by Martin R
In Swift 3 many global C functions are mapped to member functionsof the corresponding type, compare "Import as member"on swift-evolution.
在 Swift 3 中,许多全局 C 函数被映射到 相应类型的成员函数,比较 swift-evolution 上的“导入为成员”。
In your case it would be
在你的情况下,它会是
let rotate = CGAffineTransform(rotationAngle: 1.0)
let stretchAndRotate = rotate.scaleBy(x: 0.8, y: 0.8)