How do I apply a tint to the background of a UITableView
using the grouped style? The standard "color" used ([UIColor groupTableViewBackgroundColor]
) is tinted blue; I want a green tint instead.
开发者_如何学编程This uses a pattern rather than a true color. I just want to tint that pattern to match the colors I'm using elsewhere, not replace it with a solid color.
The easiest way is to make a screenshot of the default grouped tableview background and crop it so that its size is 7x1 pixels (that's enough to tile it). Adjust the tint color (hue, saturation, brightness) in your favorite image editor and use the resulting image as a pattern color via +colorWithPatternImage:
, e.g.:
myTableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"GreenStripes.png"]];
You could probably do this somehow with coregraphics by drawing the grouped tableview color to a context, tinting it, and then using a bitmap of the context as a repeated background for your tableview somehow. I couldn't tell you just how to do that, though.
Why not just do the tinting in Photoshop or GIMP or something and save it as a 32x480 (or whatever res you need) image, and use that image as your tableview's background image. To get the initial pinstripe image, just make a fullscreen view with that as the background color.
A third option would be to place a translucent green view above another view with the grouped tableview background color. Don't know how well that would work, though.
精彩评论