如何更改UITextView中文本的颜色?
yourTextView.textColor = [UIColor redColor];
在文档中查找UITextView会立即给出以下结果。;-)
最终,setTextColor:
是答案,之前的回答缺少一个重要细节: 在iOS 8中使其生效,我必须在设置文本后设置颜色。
因此,
- (void)viewDidLoad
{
[super viewDidLoad];
_myTextView.textColor = [UIColor whiteColor];
_myTextView.text = @"yadda yadda yadda...";
// etc., snip
没有工作,而
- (void)viewDidLoad
{
[super viewDidLoad];
_myTextView.text = @"yadda yadda yadda...";
_myTextView.textColor = [UIColor whiteColor];
// etc., snip
DID work. 这让我觉得是iOS 8中的一个错误,我会写一篇文章来记录它。
_textView.selectable = true;
yourTextView.
然后按ESC键,它会弹出一个属性列表供你设置。最好先浏览一下这个列表,像这样的简单问题可以通过先看一眼来轻松解决。 - Thomas Clayson