UITextView highlightTextColor或类似的选项? [英] UITextView highlightedTextColor or similar option?
问题描述
我有一个自定义 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屋!