iPhone - 将视角应用于CALayer时的锯齿状边缘 [英] iPhone - Jagged Edges when applying perspective to CALayer
问题描述
我有一个CALayer,我应用透视图来使用 CGTransform3D
并指定 m14
属性。应用透视时,图层具有锯齿状边缘。我听说有人提到在图层周围添加1px透明边框会有助于此。我不知道该怎么做。我已尝试使用CALayer的 border
和 borderWidth
属性,但锯齿状边缘仍然存在。我也试图减少所有方面1px绘制的矩形,但它也没有帮助。
任何帮助都会很棒!谢谢!
通过我听过人们提到,我认为你的意思是关于这个问题。建议实际绘制CALayer中的内容,使其在核心内容之外有一个像素透明边框,使用代码
CGContextSetAllowsAntialiasing(theContext,true);
CGContextSetShouldAntialias(theContext,true);
在该图层的Quartz图形中。
<在CALayer上还有
edgeAntialiasingMask
属性,但在使用如下代码时我没有看到任何影响: layer.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge;
关于变换图层边缘的抗锯齿。另请参阅此问题,以便对此进行讨论,以及它们如何使用图像周围的单像素透明边框解决了他们的问题。
I have a CALayer that I apply a perspective to using a CGTransform3D
and specifying the m14
property. When the perspective is applied, the layer has jagged edges. I've heard people mention that adding a 1px transparent border around the layer will help with this. I don't know how to do that. I have tried using the border
and borderWidth
properties of a CALayer but the jagged edges are still there. I also tried to reduce the rect that is drawn by 1px on all sides, but it doesn't help either.
Any help would be great! Thanks!
By "I've heard people mention," I assume you mean the discussion on this question. What was suggested there was to actually draw the content in your CALayer so that it has a one-pixel transparent border outside of the core content, using the code
CGContextSetAllowsAntialiasing(theContext, true);
CGContextSetShouldAntialias(theContext, true);
within your Quartz drawing for that layer.
There's also the edgeAntialiasingMask
property on CALayer, but I've seen no impact when using code like the following:
layer.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge;
on the antialiasing of transformed layer edges. See also this question for discussion of this, as well as how they solved their problem using one-pixel transparent borders around their images.
这篇关于iPhone - 将视角应用于CALayer时的锯齿状边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!