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;
前三个符号以黄色绘制,但背景不会改变.有任何想法吗?
解决方法 我认为CATextLayer类使用CoreText API进行渲染. CoreText API非常低级,仅支持NSAttributedString属性的子集.不幸的是,NSBackgroundcolorAttributename不是其中之一.你必须手动处理它(见 this SO entry). 总结以上是内存溢出为你收集整理的objective-c – CATextLayer不绘制NSAttributedString背景颜色全部内容,希望文章能够帮你解决objective-c – CATextLayer不绘制NSAttributedString背景颜色所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)