如何从我的CATiledLayer中删除那些旋转错误? [英] How do I remove those rotation artefacts from my CATiledLayer?
问题描述
我有一个CATiledLayer,在其中以以下方法呈现内容
I have a CATiledLayer into which I render content in the following method
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
我使用QuartzDemo代码来绘制模式。这个工作得很好,直到我对图层的parentLayer(一个UIView)应用旋转变换:
I used the QuartzDemo code to draw a pattern. This works very well until I apply a rotation transform to the layer's parentLayer (a UIView):
旋转:
当我开始在CATiledLayer中绘制线条和文本时,这些锯齿形错误会变得更糟。
These zigzag artefacts become worse when I start drawing lines and texts into the CATiledLayer.
我应用了转换如下(我也试图对视图本身使用仿射变换):
I applied the transform as follows (I also tried using an affine transform on the view itself):
self.containerView.layer.transform = CATransform3DMakeRotation(angleRadians, 0.0f, 0.0f, 1.0f);
我转换containerView而不是图层本身,因为我有几个视图层,
I transform the containerView rather than the layer itself, as I have several layers in that view that I would like to rotate at the same time without changing the relative positions.
在过去旋转UIImageView时没有问题。
I did not have problems when rotating UIImageViews in the past.
有没有办法,我可以旋转CATiledLayer没有这些问题?
Is there a way that I can rotate the CATiledLayer without these problems?
任何帮助将非常感激。
您的,
Felix
推荐答案
只有解决这个问题的方法,我发现这是:
The only way of fixing this issue I found was this:
- 将图层绘制到位图上下文
- 将该上下文的CGImageRef设置为图层内容
这篇关于如何从我的CATiledLayer中删除那些旋转错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!