我在我的智慧结束。我试过我认为是一切的东西,以摆脱CATextLayer
模糊无济于事。无可否认,有些东西是有帮助的,但是当放大到2倍并且无法接近非CATextLayer
文本的清晰度时,文本仍然太模糊。模糊CATextLayer与规模变换
这是我的情况。我有一个可以包含许多子图层的图层托管视图,其中包括CATextLayers
(位于自定义的CALayer
容器内)。现在,用户可以缩放主要内容层(其包含所有子层内容),并且通过对内容层应用缩放变换来完成。
这是我目前正在做的事情。大多数有所作为,但不是很大的区别。如果我一路放大(这是2倍缩放因子),我会得到严重模糊的文字。
确保整体坐标 - 工程,使有明显的差异,但在2倍仍然过于模糊规模
关闭阴影上
CATextLayer
容器层 - 使一个区别不是2x缩放确保文本图层的背景颜色完全不透明 - 似乎有所作为,但不是以2倍的比例
设置
contentsScale
属性为所有层窗口的支持比例因子 - 似乎有所作为虽然不是在2x缩放这个自定义CATextLayer
子顺利,抗混叠和子像素的覆盖
-drawInContext:
量化地狱的一切 - 字体呈现更真实得多,但仍处于2x缩放模糊
的代码片段:
- (void) drawInContext:(CGContextRef)context
{
// Allow font smoothing.
CGContextSetAllowsAntialiasing(context, YES);
CGContextSetAllowsFontSmoothing(context, YES);
CGContextSetAllowsFontSubpixelPositioning(context, YES);
CGContextSetAllowsFontSubpixelQuantization(context, YES);
// Set drawing attributes.
CGContextSetStrokeColorWithColor(context, self.foregroundColor);
CGContextSetFillColorWithColor(context, self.backgroundColor);
CGContextFillRect(context, self.bounds);
// Font smoothing.
CGContextSetShouldAntialias(context, YES);
CGContextSetShouldSmoothFonts(context, YES);
CGContextSetShouldSubpixelPositionFonts(context, YES);
CGContextSetShouldSubpixelQuantizeFonts(context, YES);
[super drawInContext:context];
}
我缺少什么?