[IOS]How does uitableview cell remain highlighted?
原创
©著作权归作者所有:来自51CTO博客作者james_karon的原创作品,请联系作者获取转载授权,否则将追究法律责任
参考:https://stackoverflow.com/questions/1840614/why-does-uitableview-cell-remain-highlighted
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// Unselect the selected row if any
NSIndexPath* selection = [self.tableView indexPathForSelectedRow];
if (selection) {
[self.tableView deselectRowAtIndexPath:selection animated:YES];
}
}
改变table cell的点击颜色和字体:
//set clicked color
UIView *selectedBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.width, [ScreenAdaptUtil scalingSwitch:36])];
selectedBackgroundView.backgroundColor = [UIColor colorWithRed:33/255.0 green:33/255.0 blue:33/255.0 alpha:1.0];
cell.selectedBackgroundView = selectedBackgroundView;
cell.textLabel.highlightedTextColor = [UIColor colorWithRed:240/255.0 green:208/255.0 blue:168/255.0 alpha:1.0];