【发布时间】:2012-07-30 19:33:12
【问题描述】:
我正在尝试设置数组中所有范围的颜色,但出现此错误。我不明白为什么。范围都是有效的。我什至尝试手动插入一个范围来测试它。谢谢。
CGContextSetFillColorWithColor: 无效上下文 0x0
NSMutableAttributedString * string = [[NSMutableAttributedString alloc] initWithString:tv.text];
for (NSString * s in array) {
[string addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSRangeFromString(s)];
}
CATextLayer *textlayer = [[CATextLayer alloc]init];
textlayer.frame = CGRectMake(0, 0, 320, 480);
[self.view.layer addSublayer:textlayer];
textlayer.string = @"aString"; //works
textlayer.string = string; //does not work
tv.text = @"";
【问题讨论】:
标签: iphone objective-c ios ios5 ios4