在自定義TableViewCell的時(shí)候遇到這樣一個(gè)問(wèn)題捍壤,本想不使用TableView自帶的separator,而是自己用UIView畫(huà)出一條分隔線鞍爱。
結(jié)果在選中某行Cell的時(shí)候鹃觉,這條分隔線就消失了,解決辦法:
- 重寫(xiě)
-setSelected:animated:
和-setHighlighted:animated:
方法
// 分隔線
@property (nonatomic, weak) IBOutlet UIView *separatorLine;
// override
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
[super setHighlighted:highlighted animated:animated];
self.separatorLine.backgroundColor = [UIColor b lackColor];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
self.separatorLine.backgroundColor = [UIColor blackColor];
}