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