0

I can get color hex from RGB. Now, is there any way to get color hex from colorWithHue?

    return [UIColor colorWithHue:180.0f / 360.0f    saturation:0.02f    brightness:0.85f    alpha:0.8f];
arodriguezdonaire
  • 5,396
  • 1
  • 26
  • 50
Sue
  • 125
  • 1
  • 2
  • 14

3 Answers3

0

The following link does a good job showing you how to! It also has several code snippets! :-) You can also use the calculator on the same website to check if your calculations are correct!

The Link

hhyder
  • 71
  • 6
0

You can use this method too i guess: How can I get a hex string from UIColor or from rgb

- (NSString *)hexStringForColor:(UIColor *)color {
      const CGFloat *components = CGColorGetComponents(color.CGColor);
      CGFloat r = components[0];
      CGFloat g = components[1];
      CGFloat b = components[2];
      NSString *hexString=[NSString stringWithFormat:@"%02X%02X%02X", (int)(r * 255), (int)(g * 255), (int)(b * 255)];
      return hexString;
}

UIColor *color = [UIColor colorWithHue:180.0f / 360.0f saturation:0.02f brightness:0.85f alpha:0.8f]; return [self hexStringForColor:color];

Community
  • 1
  • 1
Vlk
  • 99
  • 5
0

colorWithHue method of UIColor class returns an UIColor object. You can then use the following category to get the hex code.

https://github.com/burhanuddin353/TFTColor

[UIColor hexStringForColor:[UIColor colorWithHue:180/360.0f saturation:0.02f brightness:0.85f alpha:0.8f]];
Burhanuddin Sunelwala
  • 5,318
  • 3
  • 25
  • 51