2011-08-27 15 views
7

Creé el modificador en cellForRowAtIndexPath de esta manera.¿Qué significa esto? initWithFrame: CGRectZero]

UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; 

CGRectZero es equivalente a CGRectMake (0,0,0,0). Pero el cambio se ve en tamaño normal. No he especificado el tamaño real. Por favor, explíqueme cómo funciona el código anterior.

Respuesta

6

UISwitch no se puede personalizar, esto también se aplica al tamaño.

UISwitch anula initWithFrame: e impone un tamaño apropiado para el control. Los componentes de tamaño del rectángulo dado se ignoran.

+0

realidad UISwitch anula sizeThatFits: pero el efecto es el mismo. – progrmr

0

Cualquier objeto UIView puede anular el tamaño del marco implementando el método sizeThatFits: de UIView. De hecho, el UIView class reference dice que:

un objeto UISwitch devuelve un valor de tamaño fijo que representa el tamaño estándar de un interruptor de vista

Cuestiones relacionadas