Evelyn
Evelyn

Reputation: 2656

How do I convert RGB into HSV in Cocoa Touch?

I want to set the background color of a label using HSV instead of RGB. How do I implement this into code?

Code:

//.m file

#import "IBAppDelegate.h"

@implementation IBAppDelegate


@synthesize label;

{
self.label.backgroundColor = [UIColor colorWithRed:1.0f
                                             green:0.8f
                                              blue:0.0f
                                             alpha:1.0f];
}

Upvotes: 2

Views: 1786

Answers (1)

arul
arul

Reputation: 14084

You can use the following convenience constructor of the UIColor object:

+ (UIColor *)colorWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha

Upvotes: 7

Related Questions