标准的苹果蓝是什么颜色?

问题描述 投票:0回答:6

这是摘录自...

//
//  UIColor.h
//  UIKit
//
//  Copyright (c) 2005-2013, Apple Inc. All rights reserved.
//

 ........ 

// Some convenience methods to create colours.
// These colors will be as calibrated as possible.
// These colors are cached.
+ (UIColor *)blackColor;      // 0.0 white 
+ (UIColor *)darkGrayColor;   // 0.333 white 
+ (UIColor *)lightGrayColor;  // 0.667 white 
+ (UIColor *)whiteColor;      // 1.0 white 
+ (UIColor *)grayColor;       // 0.5 white 
+ (UIColor *)redColor;        // 1.0, 0.0, 0.0 RGB 
+ (UIColor *)greenColor;      // 0.0, 1.0, 0.0 RGB 
+ (UIColor *)blueColor;       // 0.0, 0.0, 1.0 RGB 
+ (UIColor *)cyanColor;       // 0.0, 1.0, 1.0 RGB 
+ (UIColor *)yellowColor;     // 1.0, 1.0, 0.0 RGB 
+ (UIColor *)magentaColor;    // 1.0, 0.0, 1.0 RGB 
+ (UIColor *)orangeColor;     // 1.0, 0.5, 0.0 RGB 
+ (UIColor *)purpleColor;     // 0.5, 0.0, 0.5 RGB 
+ (UIColor *)brownColor;      // 0.6, 0.4, 0.2 RGB 
+ (UIColor *)clearColor;      // 0.0 white, 0.0 alpha 

令人难以置信的是,它们不包括“标准苹果‘蓝色按钮’”........

enter image description here

在项目中,我们总是有这样的情况:但这有点疯狂。

#define APPLEBLUE [UIColor \
  colorWithRed:0/255.0 green:122/255.0 blue:255/255.0 alpha:1.0]

或者,你可以做一些像这样极其复杂的事情......

@implementation SomeButtons
{
UIColor *defaultColor;
}

-(id)initWithFrame:(CGRect)frame
    {
    defaultColor = [UIColor redColor];
    if(self = [super initWithFrame:frame])
        {
        for (UIView *v in self.subviews)
          if ([v isKindOfClass:[UIButton class]])
            defaultColor = [(UIButton *)v titleColorForState:UIControlStateNormal];
        }
    return self;
    }

-(id)initWithCoder:(NSCoder *)aCoder
    {
    if(self = [super initWithCoder:aCoder])
        {
        for (UIView *v in self.subviews)
          if ([v isKindOfClass:[UIButton class]])
            defaultColor = [(UIButton *)v titleColorForState:UIControlStateNormal];
        }
    return self;
    }

这似乎令人难以置信,没有一种更简单的方法可以让按钮和文本颜色返回“标准 Apple 控制蓝色”。

这就是 Android 程序员嘲笑我们的事情:/有人知道更简单的方法吗?我真的希望我错过了一些明显的东西。干杯

ios uibutton uicolor
6个回答
44
投票

有点晚了,但您可以在Apple的人机界面指南中找到颜色值。

蓝色的是

(R, G, B) = (0, 122, 255) = #007AFF

为了方便起见,我创建了一个带有 UIColor 扩展的 GIST


12
投票

尝试一下数字色度计?它似乎在想(14, 122, 254)。

enter image description here

然后添加类别:

@implementation UIColor (MyColors)

+ (UIColor*)appleBlue {
    return [UIColor colorWithRed:14.0/255 green:122.0/255 blue:254.0/255 alpha:1.0];
}

@end

7
投票

从 iOS 7 开始,你可以简单地使用这个:

UIColor.systemBlue

5
投票

用它来快速:

extension UIColor {
    static func appleBlue() -> UIColor {
        return UIColor.init(colorLiteralRed: 14.0/255, green: 122.0/255, blue: 254.0/255, alpha: 1.0)
    }
}

5
投票

如果您只是寻找 RGB 十六进制代码,请看这里:

'#0E7AFE'


0
投票

更新了 Apple 人机界面链接来自顶部评论

© www.soinside.com 2019 - 2024. All rights reserved.