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

| Última modificación: 15 de abril de 2024 | Tiempo de Lectura: 1 minutos
Premios Blog KeepCoding 2025

iOS Developer & Co-Fundador de 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;

Noticias recientes del mundo tech


¡CONVOCATORIA ABIERTA!

Desarrollo de apps móviles ios & Android

Full Stack Bootcamp

Clases en Directo | Profesores en Activo | Temario 100% actualizado

Descárgate también el informe de tendencias en el mercado laboral 2026.

Fórmate con planes adaptados a tus objetivos y logra resultados en tiempo récord.
KeepCoding Bootcamps
Resumen de privacidad

Esta web utiliza cookies para que podamos ofrecerte la mejor experiencia de usuario posible. La información de las cookies se almacena en tu navegador y realiza funciones tales como reconocerte cuando vuelves a nuestra web o ayudar a nuestro equipo a comprender qué secciones de la web encuentras más interesantes y útiles.