[IOS]How does uitableview cell remain highlighted?

参考: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];

 

猜你喜欢

转载自jameskaron.iteye.com/blog/2393736