我正在尝试创建一个可以在 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();
}
这段短片在两种设备上都会产生清晰的文本,但不幸的是,它在两种设备上都会产生模糊的文本。它的显示方式如下:
丑陋的文本http://files.droplr.com.s3.amazonaws.com/files/16285043/1gBp61.Screen%20shot%202010-06-26%20at%2021:25:09.png http://files.droplr.com.s3.amazonaws.com/files/16285043/1gBp61.Screen%20shot%202010-06-26%20at%2021:25:09.png
该图像是在 iPhone 4 上以 100% 变焦拍摄的。这到底是怎么回事?我有什么想法可以解决这个问题吗?