Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the iOS 7 default blue color programmatically?

Use self.view.tintColor from a view controller, or self.tintColor from a UIView subclass.


It appears to be [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0].

screenshot showing Colors window


iOS 7 default blue color is R:0.0 G:122.0 B:255.0

UIColor *ios7BlueColor = [UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0];

According to the documentation for UIButton:

In iOS v7.0, all subclasses of UIView derive their behavior for tintColor from the base class. See the discussion of tintColor at the UIView level for more information.

Assuming you don't change the tintColor before grabbing the default value, you can use:

self.view.tintColor

Here is a simple method to get the default system tint color:

+ (UIColor*)defaultSystemTintColor
{
   static UIColor* systemTintColor = nil;
   static dispatch_once_t onceToken;
   dispatch_once(&onceToken, ^{
      UIView* view = [[UIView alloc] init];
      systemTintColor = view.tintColor;
   });
   return systemTintColor;
}

Hex Color code

#007AFF

and you need this libary https://github.com/thii/SwiftHEXColors

ps. iOS, Swift


swift 4 way:

extension UIColor {
  static let system = UIView().tintColor!
}