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

Contenido del Bootcamp Dirigido por: | Última modificación: 15 de abril de 2024 | Tiempo de Lectura: 1 minutos

Algunos de nuestros reconocimientos:

Premios KeepCoding

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 más leídos