解决UITableViewCell被选中时UILabel的背景颜色变成透明

来源:互联网 发布:淘宝图片尺寸不合法 编辑:程序博客网 时间:2024/05/06 12:16

解决方法是:继承一个新的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

0 0
原创粉丝点击