IPhone, you need a blue color, like UIColor (used in text tables) # 336699

I am trying to assign blue text like this in the same way

alt text

I use my own text box.

In hex color # 336699

I need to access the color of this text, I would like to use UIColor, but it seems not one.

+3
source share
4 answers

UIColorneeds values ​​in RGB / 255.0f. You can find the converter here . In your case, your color is R: 51, G: 102, B: 153.

So, the code to get UIColor:

UIColor *myColor = [UIColor colorWithRed:51.0f/255.0f green:102.0f/255.0f blue:153.0f/255.0f alpha:1.0f];
+9
source

I wrote a category for UIColor to convert hexagon colors to UIColors

+ (UIColor *)colorWithHex:(UInt32)col {
    unsigned char r, g, b;
    b = col & 0xFF;
    g = (col >> 8) & 0xFF;
    r = (col >> 16) & 0xFF;
    return [UIColor colorWithRed:(double)r/255.0f green:(double)g/255.0f blue:(double)b/255.0f alpha:1];
}

UIColor *newColor = [UIColor colorWithHex:0x336699];
+4
source

, - , - , . Slate Blue, Apple:

[UIColor colorWithRed:0.22f green:0.33f blue:0.53f alpha:1.0f]

:

@interface UIColor (mxcl)
+ (UIColor *)slateBlueColor;
@end
@implementation UIColor (mxcl)
+ (UIColor *)slateBlueColor { return [UIColor colorWithRed:0.22f green:0.33f blue:0.53f alpha:1.0f]; }
@end
+2
source
0
source

Source: https://habr.com/ru/post/1769771/


All Articles