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 时出现锯齿状边缘
基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01