4
我有CATextLayer並且想要設置背景顏色爲部分字符串。但是將背景顏色設置爲屬性字符串(NSBackgroundColorAttributeName)沒有任何作用。其他屬性(如前景色)正確應用。CATextLayer不繪製NSAttributedString背景顏色
NSMutableAttributedString *str = [[[NSMutableAttributedString alloc] initWithString:@"Some Text"] autorelease];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSColor yellowColor], NSForegroundColorAttributeName,
[NSColor redColor], NSBackgroundColorAttributeName, nil];
[str setAttributes:attributes range:NSMakeRange(0, 3)];
textLayer.string = str;
前三個符號用黃色繪製,但背景不會改變。有任何想法嗎?