gpt4 book ai didi

iphone - 丰富的 UITextView 中不显示文本属性 (iOS 6)

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:04:02 26 4
gpt4 key购买 nike

我正在尝试为 iOS 6 UITextView 中的一些初始文本设置字体颜色。在 UI 6 模拟器中运行时,出现 View ,但未呈现属性。我错过了什么吗?

NSAttributedString *as = [[NSAttributedString alloc] initWithString:boilerText
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
NSForegroundColorAttributeName, [UIColor redColor] ,
NSUnderlineStyleAttributeName,
[NSNumber numberWithInt: NSUnderlineStyleSingle],nil]
];

_descriptionView.attributedText = as;

最佳答案

该方法表示 dictionaryWithObjectsAndKeys。你已经把你的对象和键颠倒了。试试这个:

NSAttributedString *as = [[NSAttributedString alloc] initWithString:boilerText
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], NSForegroundColorAttributeName,
[NSNumber numberWithInt: NSUnderlineStyleSingle], NSUnderlineStyleAttributeName,
nil]];

关于iphone - 丰富的 UITextView 中不显示文本属性 (iOS 6),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12818217/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com