如何设置Section标题的RGB颜色值 - IOS

Fer*_*roz 4 iphone xcode objective-c ios

我尝试使用以下代码作为标题视图.它不起作用.如何设置默认颜色值以外的颜色.

[header_view setBackgroundColor:[UIColor colorWithRed:10. green:0 blue:0 alpha:0]];
Run Code Online (Sandbox Code Playgroud)

AJS*_*AJS 11

[header_view setBackgroundColor:[UIColor colorWithRed:10/255.0 green:0/255.0 blue:0/255.0 alpha:1]];
Run Code Online (Sandbox Code Playgroud)


bit*_*com 7

请参阅UIColor.h标头.将在下面显示.

+ (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 
Run Code Online (Sandbox Code Playgroud)

因为上面的颜色是相同的代码.

black:       [UIColor colorWithWhite:0.0f alpha:1.0f];
darkGray:    [UIColor colorWithWhite:0.333f alpha:1.0f];
lightGray:   [UIColor colorWithWhite:0.667f alpha:1.0f];
white:       [UIColor colorWithWhite:1.0f alpha:1.0f];
gray:        [UIColor colorWithWhite:0.5f alpha:1.0f];
red:         [UIColor colorWithRed:255/255.0f green:0/255.0f blue:0/255.0f alpha:1.0f];
green:       [UIColor colorWithRed:0/255.0f green:255/255.0f blue:0/255.0f alpha:1.0f];
blue:        [UIColor colorWithRed:0/255.0f green:0/255.0f blue:255/255.0f alpha:1.0f];
.
.
.
Run Code Online (Sandbox Code Playgroud)

如果你想如何将颜色rgb值应用于UIColor.见下面的帖子

你想要颜色找到维基百科或其他网站.

在此输入图像描述

r,g,b值适用如下.

[UIColor colorWithRed:158/255.0f green:253/255.0f blue:56/255.0f alpha:1.0f];
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述