[IOS]How does uitableview cell remain highlighted?

 

Reference: 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];
    }
}

 

Change the click color and font of the 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];

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326125269&siteId=291194637