开发者

How do you change the color of text in a UITextView?

How do y开发者_如何学Pythonou change the color of text in a UITextView?


yourTextView.textColor = [UIColor redColor];

Looking up UITextView in the documentation gives this immediately. ;-)


In the end, setTextColor: is the answer, there's an important detail missing from the earlier answers: To get this to work in iOS 8, I had to set the color =after= I set the text.

Hence,

- (void)viewDidLoad
{
    [super viewDidLoad];

    _myTextView.textColor = [UIColor whiteColor];
    _myTextView.text   = @"yadda yadda yadda...";

    // etc., snip

Did NOT work, while

- (void)viewDidLoad
{
    [super viewDidLoad];

    _myTextView.text   = @"yadda yadda yadda...";
    _myTextView.textColor = [UIColor whiteColor];

    // etc., snip

DID work. This strikes me as a bug in iOS 8, which I will write up.


I spot that setting

_textView.selectable = true;

solves that strange issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜