【问题标题】:IOS - When I rotate a UIView the edges become distortedIOS - 当我旋转 UIView 时,边缘会变形
【发布时间】:2016-10-13 09:38:09
【问题描述】:

我尝试使用以下方法旋转 UIView:

view.transform = CGAffineTransform.init(rotationAngle: 45)

只看到视图的边缘看起来很扭曲。 这是正常的吗?如果是,是否有任何变通方法来拉直边缘?

编辑

我发现添加下面这段代码效果最好

view.layer.allowsEdgeAntialiasing = true

【问题讨论】:

  • 可以添加截图吗?
  • 看起来仍然很扭曲。我也在自己的 ios 设备上运行了这个,得到了相同的结果。
  • 试试这个,stackoverflow.com/a/12066215/6742121 并检查我对 swift 3.0 的回答。 @BrandonCornelio
  • 谢谢!这很有帮助
  • 不客气。 @BrandonCornelio

标签: ios swift swift3


【解决方案1】:

参考这个链接,

https://stackoverflow.com/a/8313978/6742121,

之后为 swift 3.0 实现这个,

view.layer.borderWidth = 3
view.layer.borderColor = UIColor.clear.cgColor
view.layer.shouldRasterize = true
view.layer.rasterizationScale = UIScreen.main.scale()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-22
    • 2018-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-18
    • 2011-04-23
    相关资源
    最近更新 更多