Styling UITableViewCells with gradient backgrounds

I work for Tumblr, and while I didn’t write the iPhone app (he did), I have the source and can tell you how it’s done.

In -tableView:cellForRowAtIndexPath:

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"postCellBackground.png"]];
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"postCellBackgroundSelected.png"]];

Pretty simple, really: PNG images in a UIImageView as the cell’s background views.

The two images are 1×61 vertical gradients that UIKit automatically stretches horizontally to fit the width of the cell.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)