Reputation: 39019
I want to create a UILabel
and set its background to the gradient-blue like a selected UITableViewCell
. I suspect I need to use UIColor colorWithPatternImage:
. If yes, I am not sure what the best way to get the pattern image is. Or, any other suggestions on how to accomplish this?
I would prefer not to create a pre-rendered background image since I need this to work on iPhone 3GS, 4 and iPad which all will require different background images.
Upvotes: 0
Views: 1772
Reputation: 253
Your_label_name.backgroundColor = [UIColor colorWithRed:72.0/255.0 green:118.0/255.0 blue:255.0/255.0 alpha:1.0];
also refer this link : http://cloford.com/resources/colours/500col.htm
Upvotes: 0
Reputation: 26476
The image used by Apple is UITableSelection.png. I have attached the standard and @2x images.
UIView *selectedView = [[UIView alloc] initWithFrame:self.bounds];
selectedView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"UITableSelection.png"]];
cell.selectedBackgroundView = selectedView;
Upvotes: 2
Reputation: 1574
It's an undocumented color, I'm not sure if you'd want to use an undocumented color. But it's called
[UIColor tableSelectionColor]
Also, it doesn't have the gradient effects that you want. I assume it's a gradient overlay applied to the cell? I don't know how apple does it, but if you wanted to know the color, that's what it is. the RGB values are 0.16, 0.43, 0.83 respectively.
Upvotes: 1
Reputation: 17372
Cool post here on customising cell appearance...
http://www.raywenderlich.com/2033/core-graphics-101-lines-rectangles-and-gradients
Upvotes: 1