CATextLayer字體模糊問題
把其中的幾個字變深色一點或者變顏色,代碼如下:NSMutableAttributedString *attriString = [[[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Promotion", nil)]
autorelease];
[attriString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor colorWithRed:255 green:200 blue:0 alpha:1].CGColor range:NSMakeRange(0,124)];
[attriString addAttribute:(NSString *)kCTForegroundColorAttributeName
value:(id)[UIColor redColor].CGColor
range:NSMakeRange(124, 6)];
[attriString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor colorWithRed:255 green:200 blue:0 alpha:1].CGColor range:NSMakeRange(130,10)];
CATextLayer *textLayer = [CATextLayer layer];
textLayer.string = attriString;
textLayer.fontSize=15;
textLayer.frame = CGRectMake(0, 20, 280, 160);
textLayer.backgroundColor=[[UIColor clearColor]CGColor];
//需要設置CALayer的contentsScale屬性。這個值來自於屏幕的backingScaleFactor, contentsScale = 2表示retina屏幕;
textLayer.contentsScale = 2;
[whiteBackground.layer addSublayer:textLayer];