Changing background color of selected cell?

后端 未结 30 2959
太阳男子
太阳男子 2020-11-29 00:22

Does anyone know how to change the background color of a cell using UITableViewCell, for each selected cell? I created this UITableViewCell inside the code for TableView.

30条回答
  •  被撕碎了的回忆
    2020-11-29 00:49

    Changing the property selectedBackgroundView is correct and the simplest way. I use the following code to change the selection color:

    // set selection color
    UIView *myBackView = [[UIView alloc] initWithFrame:cell.frame];
    myBackView.backgroundColor = [UIColor colorWithRed:1 green:1 blue:0.75 alpha:1];
    cell.selectedBackgroundView = myBackView;
    [myBackView release];
    

提交回复
热议问题