解決方法是:繼承一個(gè)新的UILabel
類,重寫setBackgroundColor:
方法,讓這個(gè)方法不能改變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