BObereder
BObereder

Reputation: 1046

how to set tableViewCell background to black gradient like navigationbar

I have set up my own custom tableViewCell and want to the background to be the same black gradient as my navigationBar with style UIBarStyleBlackOpaque.

what would be the best way to do that ?

Upvotes: 0

Views: 348

Answers (1)

Evan Mulawski
Evan Mulawski

Reputation: 55334

Use the key combination CMD-SHIFT-4 to capture a 1 pixel wide image of the navigation bar's gradient. The image will be saved on your desktop (you can use Preview to crop, etc.). Add the image to your project. In -tableView:cellForRowAtIndexPath:, use:

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

UIKit automatically stretches the gradient horizontally to fit the width of the cell.

Upvotes: 2

Related Questions