2010-07-20 10 views

Respuesta

3

Una idea es colocar un UIImage con una imagen estirable. De esta forma, no importa cuál sea la altura de la fila, la imagen puede estirarse para coincidir.

También puede hacer algo similar a lo que Matt ha hecho here with a gradient layer

+0

¿Puedes describir la imagen estirable? ¿Necesitaré crear alguna imagen de 1x55 píxeles (solo un ejemplo) y que se extenderá automáticamente sobre el plano x o se necesita un código adicional? –

+3

Básicamente solo das una imagen y luego le dices qué partes no son estirables mediante '[[UIImage imageNamed: @" someBGImage.png "] stretchableImageWithLeftCapWidth: 5 topCapHeight: 5];' donde los 5 píxeles son la parte que no está ' t estirable (como un borde). Más información http://developer.apple.com/iphone/library/documentation/uikit/reference/UIImage_Class/Reference/Reference.html#//apple_ref/occ/instm/UIImage/stretchableImageWithLeftCapWidth:topCapHeight: – iwasrobbed

2

En el método cellForRowAtIndexPath se puede dar color de fondo de células

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 


{ 
    static NSString *cellIdentifier = @"Cell"; 
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

    if (cell == nil) 
    {  
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 
    } 
// for cell background color 
    cell.backgroundView =[[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"tab2.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]; 

// for selection color  
    cell.selectedBackgroundView =[[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"selected.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]; 
    return cell; 
} 
Cuestiones relacionadas