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

后端 未结 15 1134
一整个雨季
一整个雨季 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:54

    From iOS 7 there is an API and you can get (and set) the tint color with:

    self.view.tintColor
    

    Or if you need the CGColor:

    self.view.tintColor.CGColor
    
    0 讨论(0)
  • 2020-12-22 16:56

    In many cases what you need is just

    [self tintColor] 
    // or if in a ViewController
    [self.view tintColor]
    

    or for swift

    self.tintColor
    // or if in a ViewController
    self.view.tintColor
    
    0 讨论(0)
  • 2020-12-22 16:57

    Adding a category to UIColor the following way will make it available to you anytime you need it or even change its definition accross your code:

    @interface UIColor (iOS7Colors)
    
    + (instancetype)iOS7blueColor;
    
    @end
    
    @implementation UIColor (SpecialColors)
    
    + (instancetype)iOS7blueColor;
    {
        return [UIColor colorWithRed:0.0f green:0.22f blue:122.0/255.0 alpha:1.0f];
    }
    

    Once you import the Category in your code you can call the color by using:

    UIColor *myBlueColor = [UIColor iOSblueColor];
    
    0 讨论(0)
提交回复
热议问题