UIView旋转使用swift问题

时间:2017-06-07 11:08:15

标签: ios swift rotation cgaffinetransform

我想轮换在我使用的故事板上定义的UIView

CGAffineTransform(rotationAngle: self.degreesToRadians(5))

其中degreeToradians是一个转换为Radians的函数,旋转工作完美,但唯一的问题是UIView不是矢量(视图的边缘没有正确渲染,看起来像锯),如下面的截图所示: / p>

enter image description here

1 个答案:

答案 0 :(得分:3)

我遇到了和你一样的问题并解决了它我只是在视图中添加一个透明的边框,就像这样:

customView.layer.borderWidth = 1
customView.layer.borderColor = UIColor.clear.cgColor // important that it is clear
customView.layer.shouldRasterize = true
customView.layer.rasterizationScale = UIScreen.main.scale

rotation代码后添加该代码。

代码:
enter image description here

没有代码:
enter image description here