美文网首页
解决UITableViewCell被选中时UILabel的背景颜

解决UITableViewCell被选中时UILabel的背景颜

作者: 不是谢志伟 | 来源:发表于2014-04-22 16:10 被阅读1695次

解决方法是:继承一个新的UILabel类,重写setBackgroundColor:方法,让这个方法不能改变Label的背景颜色.

@interface PersistentBackgroundLabel : UILabel {
}

- (void)setPersistentBackgroundColor:(UIColor*)color;

@end


@implementation PersistentBackgroundLabel

- (void)setPersistentBackgroundColor:(UIColor*)color {
    super.backgroundColor = color;
}

- (void)setBackgroundColor:(UIColor *)color {
    // do nothing - background color never changes
}

@end

参考:UITableViewCell makes label's background clear when highlighted

相关文章

网友评论

      本文标题:解决UITableViewCell被选中时UILabel的背景颜

      本文链接:https://www.haomeiwen.com/subject/spnltttx.html