Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the UIColor of the default UITableView separator?

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.

like image 642
Alejandra Avatar asked Jun 22 '11 20:06

Alejandra


1 Answers

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().separ‌​atorColor 

As @Jordan noted in comment, you also can store the result to avoid further evaluation cost.

let defaultTableSeparato‌​rColor = UITableView().separa‌​torColor 
like image 153
eonil Avatar answered Oct 14 '22 16:10

eonil