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

2014-04-22  本文已影响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

上一篇 下一篇

猜你喜欢

热点阅读