I'm trying to assign blue text like this, exactly like this
I'm using my own text field.
In hex the color is #336699
I need to access my text color to this, I would have liked to use a UIColor but there doesn't seem to be one.
I'm trying to assign blue text like this, exactly like this
I'm using my own text field.
In hex the color is #336699
I need to access my text color to this, I would have liked to use a UIColor but there doesn't seem to be one.
UIColor
needs it's values in RGB/255.0f. You can find here a converter. In your case, your color is R:51, G:102, B:153.
So the code to get your UIColor
is then:
UIColor *myColor = [UIColor colorWithRed:51.0f/255.0f green:102.0f/255.0f blue:153.0f/255.0f alpha:1.0f];
I wrote a category for UIColor to convert hex-style 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];