我正在尝试创建一个可以在 iPhone 4 上很好地扩展的应用程序。目前,除了一个关键部分:我在 CALayer 中绘制的文本,在它的 drawInContext: 方法中,它的大部分都可以完美地扩展。这是我的代码:
- (void)drawInContext:(CGContextRef)context {
UIGraphicsPushContext(context);
CGContextSetGrayFillColor(context, 1.0f, 1.0f);
CGContextFillRect(context, self.bounds);
CGContextSetAllowsAntialiasing(context, true);
CGContextSetShouldAntialias(context, true);
CGContextSetAllowsFontSmoothing(context, true);
CGContextSetShouldSmoothFonts(context, true);
CGContextSetAllowsFontSubpixelQuantization(context, true);
CGContextSetShouldSubpixelQuantizeFonts(context, true);
CGContextTranslateCTM(context, 0.0f, self.frame.size.height);
CGContextScaleCTM(context, 1.0f, -1.0f);
CGContextSetFillColorWithColor(context, [[UIColor blackColor] CGColor]);
CGContextSelectFont(context, "CardKit", 30.0f, kCGEncodingMacRoman);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextShowText(context, "A", sizeof("A"));
UIGraphicsPopContext();
}
这段短片在两种设备上都产生了清晰的文本,但不幸的是,它在两个设备上都产生了模糊的文本。这是它的外观:
该图像是在 iPhone 4 上以 100% 缩放拍摄的。到底是什么?有什么想法可以解决这个问题吗?