开发者

how to set tableViewCell background to black gradient like navigationbar

开发者 https://www.devze.com 2023-03-05 12:26 出处:网络
I have set up my own custom tableViewCell and want to the background to be the same black gradient as my navigationBar with style UI开发者_开发技巧BarStyleBlackOpaque.

I have set up my own custom tableViewCell and want to the background to be the same black gradient as my navigationBar with style UI开发者_开发技巧BarStyleBlackOpaque.

what would be the best way to do that ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消