问题描述
试图理解为什么我使用CGContextShowTextAtPoint获得低质量的绘图?见附图:
Trying to understand why am I getting low quality drawing with CGContextShowTextAtPoint? See attached image:
字母W是在CALayer上使用CGContextShowTextAtPoint绘制的,看起来非常像素化。它旁边的按钮是一个标准按钮,按预期看起来很高。我想让文字绘图成为高分辨率。
The letter "W" is drawn using CGContextShowTextAtPoint on a CALayer and looks very pixelized. The button next to it is a standard button and looks high res as expected. I would like to get the text drawing to be hi-res.
推荐答案
默认情况下,您的CALayer不会以更高的分辨率渲染其Quartz内容Retina显示屏。你可以使用如下代码启用它:
By default, your CALayer is not rendering its Quartz content at the higher resolution of the Retina display screen. You can enable this using code like the following:
if ([layer respondsToSelector:@selector(setContentsScale:)])
{
layer.contentsScale = [[UIScreen mainScreen] scale];
}
这不仅会影响文本渲染,还会影响CALayers中的所有Quartz绘图,因此您需要使用自定义Quartz内容为所有图层执行此操作。
This will affect not just text rendering, but all of your Quartz drawing within CALayers, so you'll need to do this for all of your layers with custom Quartz content.
这篇关于Retina显示核心图形字体质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!