How to change the background color of a cell in a UITableView

Autor: | Última modificación: 15 de abril de 2024 | Tiempo de Lectura: 1 minutos
Temas en este post:

Changing the background color of a cell in a UITableView

The default value for selectedBackgroundView is nil for cells in plain-style tables (UITableViewStylePlain) and non-nil for section-group tables (UITableViewStyleGrouped). If you’re using a plain-style table, you must alloc an init a new UIView with the desired background color, and then assign it to selectedBackgroundView. Otherwise, if you just want a gray background, you should use:
cell.selectionStyle = UITableViewCellSelectionStyleGray;

Posts Relacionados