gpt4 book ai didi

swift - CGAffineTransformMakeRotation iOS 7 帧更改错误修复

转载 作者:行者123 更新时间:2023-11-28 08:33:00 26 4
gpt4 key购买 nike

CGAffineTransformMakeRotation() 在 iOS 7 上尝试将对象(标签、按钮等)旋转到不同于 90、180、360 等的角度时会生成一个奇怪的错误。

从 iOS 8 开始,这个错误就消失了。

修复在下面的答案中。

最佳答案

此错误的修复是在上应用CABasicAnimation,而不是在 View 上应用CGAffineTransformMakeRotation > 按钮。

出于某种原因,当您将它应用于 View 时,它会弄乱框架和自动版式。更多信息 here .

以下是实现此修复的方法:

let animation = CABasicAnimation(keyPath: "transform.rotation")
animation.autoreverses = false
animation.duration = 0.3
animation.fromValue = 0
animation.fillMode = kCAFillModeForwards
animation.removedOnCompletion = false
animation.toValue = 3.14/4 // 45 degrees
self.myButton.layer.addAnimation(animation, forKey: "45rotation")

关于swift - CGAffineTransformMakeRotation iOS 7 帧更改错误修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38463045/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com