Reputation: 553
Can anyone tell me the UIColor name or exact RGBA for the default iPhone UITableView separator?
It looks like a light gray color, but it's not [UIColor lightGrayColor]
; it's lighter than that.
Upvotes: 48
Views: 32885
Reputation: 574
In iOS 15.5, Separator Color Value is:
let separatorColor = UIColor.separator
// R:0.24, G:0.24, B:0.26, A:0.29
By the way, you can get this value by "Debug View Hierarchy" in Xcode.
Upvotes: 0
Reputation: 2483
In Swift 3.0.1, you can do something like this
yourView.backgroundColor = UITableView().separatorColor
Upvotes: 8
Reputation: 85955
The color is not guaranteed to be a specific color. It can be changed over OS and SDK versions.
You can retrieve exact color dynamically by accessing separatorColor
property.
UITableView* TV = [[UITableView alloc] init];
UIColor* C = [TV separatorColor];
CGColorRef CGC = [C CGColor];
Now you can get the each channel values through UIColor
's methods. Or use the CGColor
directly for drawing.
Here's header file comment of the property in UITableView.h
.
@property(nonatomic,retain) UIColor *separatorColor;
// default is the standard separator gray
If you want to avoid instantiation cost of UITableView
for each time, just get it once and cache it.
As @Isuru noted in comment, you can write in Swift like this.
UITableView().separatorColor
As @Jordan noted in comment, you also can store the result to avoid further evaluation cost.
let defaultTableSeparatorColor = UITableView().separatorColor
Upvotes: 67
Reputation: 1484
Swift 3
Just set to nil to revert to default.
tableView.separatorColor = nil
Upvotes: 19
Reputation: 690
FWIW:
UIColor *defaultSeparatorColor = [UIColor colorWithRed:0.783922f green:0.783922f blue:0.8f alpha:1.0f];
This was found simulating iOS 9.0 -- and logging out the floating point values that a UITableView separatorColor has by default. I do not find that this matches any of the values from the other answers, but rather exacts the result of the code in the other answer here where the separatorColor is set via creation of a UITableView *tempTable.
Upvotes: 2
Reputation: 802
Screenshot -> Photoshop -> Pick Color Tool -> RGB(227, 227, 229)
Upvotes: 1
Reputation: 8480
It seems it changed for iOS 7:
Now the colour is RGB(200, 199, 204):
[UIColor colorWithRed:200/255.0 green:199/255.0 blue:204/255.0 alpha:1.0];
And don't forget the proper line height is 1 px. The code for creating corresponding UIView:
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 640, 1/[[UIScreen mainScreen] scale])];
view.backgroundColor = [UIColor colorWithRed:200/255.0 green:199/255.0 blue:204/255.0 alpha:1.0];
Upvotes: 26
Reputation: 11
UITableView * tempTable = [[UITableView alloc] init];
[table setSeparatorColor:tempTable.separatorColor];
[table setSeparatorStyle:tempTable.separatorStyle];
table.backgroundView = tempTable.backgroundView;
Upvotes: 1
Reputation: 3277
[UIColor colorWithRed:224/255.0 green:224/255.0 blue:224/255.0 alpha:1.0];
Upvotes: 18
Reputation: 3176
To find out any colours on your iOS device, just run the app in the Simulator then use Apple's DigitalColor Meter (in your utilities folder) and hover over the colour you need info on. Alternatively just do a screen grab from the phone, open that in Preview and use DigitalColor Meter to read the colour values.
Upvotes: 6
Reputation: 620
… in terms of CGContextSetRGBStrokeColor
it should be:
CGContextSetRGBStrokeColor (
CGContextRef c,
224.0/255.0,
224.0/255.0,
224.0/255.0,
CGFloat alpha
);
Quite simple and hopefully a solution for your problem.
Upvotes: 41