【问题标题】:What is the standard Apple blue colour?标准的苹果蓝是什么颜色?
【发布时间】:2014-08-29 13:00:49
【问题描述】:

这是...的摘录

//
//  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 

令人难以置信的是,它们不包括“标准 Apple 'button blue'”......

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

#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 程序员嘲笑我们的那种事情:/ 有谁知道更简单的方法吗?我真的希望我遗漏了一些明显的东西。干杯

【问题讨论】:

  • 从 iOS7 开始,“标准蓝色”是视图的 tintColor。绝对不需要在应用程序的任何地方使用默认颜色。不,Apple 不会更改您应用的 tintColor。

标签: ios uibutton uicolor


【解决方案1】:

试试数字色度计?它似乎在思考 (14, 122, 254)。

然后添加一个类别:

@implementation UIColor (MyColors)

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

@end

【讨论】:

  • 在 DigitalColor Meter 中,转到查看 > 显示值 > 作为百分比。无需除以 255 :)
【解决方案2】:

将此用于快速:

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

【讨论】:

    【解决方案3】:

    有点晚了,但是你可以在 Apple 的Human interface guidelines 中找到颜色值。

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

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

    【讨论】:

    • 好的,世纪掌心。我不知何故迷上了蓝绿色,以为就是这样。常规的蓝色(也称为“蓝色”)是正确的。 :D 谢谢
    • @Fattie 完成了吗? (评论还不够长,所以等等等等)
    【解决方案4】:

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

    UIColor.systemBlue
    

    【讨论】:

      【解决方案5】:

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

      '#0E7AFE'

      【讨论】:

      • 注意:非常简短的答案和/或回帖者的问题可能应该是 cmets。你只需要 50 个代表点就可以在一个问题下发表评论 - 你能把它移到那里吗?
      • 我想我不能以我的排名 (21)。
      • 请注意,用户界面 doco 中给出的十六进制代码是 007AFF ... 现在唯一真正正确的答案是 UIColor.systemBlue
      • 我在我的应用程序中使用颜色 ''#0E7AFE'' 并且似乎很好。但我会尝试 '007AFF' 看看是否更好。
      猜你喜欢
      • 2011-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-20
      • 1970-01-01
      • 2018-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多