iPhone - Jagged Edges when applying perspective to CALayer(iPhone - 将透视图应用于 CALayer 时出现锯齿状边缘)
问题描述
我有一个 CALayer,我将透视应用到使用 CGTransform3D
并指定 m14
属性.应用透视时,图层的边缘呈锯齿状.我听说有人提到在图层周围添加一个 1px 的透明边框会有所帮助.我不知道该怎么做.我尝试使用 CALayer 的 border
和 borderWidth
属性,但锯齿状边缘仍然存在.我还尝试将在所有边上绘制 1px 的矩形减小,但这也无济于事.
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!
推荐答案
我听说有人提到过",我假设你的意思是 这个问题.建议使用代码在 CALayer 中实际绘制内容,使其在核心内容之外具有一个像素的透明边框
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);
在该层的 Quartz 绘图中.
within your Quartz drawing for that layer.
CALayer 上还有 edgeAntialiasingMask
属性,但我在使用如下代码时没有看到任何影响:
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;
关于变换层边缘的抗锯齿.另请参阅 this question 以了解有关此问题的讨论以及它们如何解决了他们在图像周围使用一像素透明边框的问题.
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 时出现锯齿状边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone - 将透视图应用于 CALayer 时出现锯齿状边缘


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01