UITextView highlightTextColor或类似的选项? [英] UITextView highlightedTextColor or similar option?

查看:125
本文介绍了UITextView highlightTextColor或类似的选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义 UITableViewCell ,带有 UILabel UITextView 在里面。

I have a custom UITableViewCell with a UILabel and a UITextView in it.

当用户突出显示 UITableViewCell 时,我希望这两个文本都显示为白色。设置 UILabel highlightTextColor 显然非常简单,但 UITextView 似乎没有任何类似的财产。每当单元格突出显示/未突出显示时,我是否必须手动更改 UITextView 的颜色?或者是否有更简单的方法来完成此操作?

I want the text for both of these to appear white when the user highlights the UITableViewCell. It's obviously very simple to set the highlightedTextColor of the UILabel, but the UITextView doesn't seem to have any similar type of property. Am I going to have to manually change the color of the UITextView whenever the cell becomes highlighted/unhighlighted or is there an easier way of accomplishing this?

谢谢!

推荐答案

找到它并且比我想象的容易得多。只需要使用 UITableViewCell setHighlighted 方法。

Found it and it was a lot easier than I thought. Just need to use the UITableViewCell setHighlighted method.

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
    [super setHighlighted:highlighted animated:animated];

    if (highlighted) {
        [self.myTextView setTextColor:[UIColor whiteColor]];
    } else {
        [self.myTextView setTextColor:[UIColor blackColor]]; 
    }

}

这篇关于UITextView highlightTextColor或类似的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆