我在我的智慧結束。我試過我認爲是一切的東西,以擺脫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];
}
我缺少什麼?