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

后端 未结 15 1133
一整个雨季
一整个雨季 2020-12-22 16:04

I\'m creating custom elements in my app and want to match the look and feel of the new iOS. iOS 7 introduced to us a very common lighter blue color, the default color or tin

相关标签:
15条回答
  • 2020-12-22 16:40

    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;
    }
    
    0 讨论(0)
  • 2020-12-22 16:42

    swift 4 way:

    extension UIColor {
      static let system = UIView().tintColor!
    }
    
    0 讨论(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
    
    0 讨论(0)
  • 2020-12-22 16:45

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

    screenshot showing Colors window

    0 讨论(0)
  • 2020-12-22 16:45

    while setting the color you can set color like this

    [UIColor colorWithRed:19/255.0 green:144/255.0 blue:255/255.0 alpha:1.0]
    
    0 讨论(0)
  • 2020-12-22 16:54

    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];
    
    0 讨论(0)
提交回复
热议问题