How do I convert RGB into HSV in Cocoa Touch?

这一生的挚爱 提交于 2019-12-11 04:06:19

问题


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];
}

回答1:


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

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


来源:https://stackoverflow.com/questions/1050874/how-do-i-convert-rgb-into-hsv-in-cocoa-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!