本文介绍了如何在Cocoa Touch中将RGB转换为HSV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用HSV而不是RGB来设置标签的背景颜色。
/ /.m file
#importIBAppDelegate.h
@implementation IBAppDelegate
@synthesize label;
{
self.label.backgroundColor = [UIColor colorWithRed:1.0f
green:0.8f
blue:0.0f
alpha:1.0f] ;
}
解决方案
UIColor
对象的构造函数:
+(UIColor *)colorWithHue: (CGFloat)色度饱和度:(CGFloat)饱和度亮度:(CGFloat)亮度alpha:(CGFloat)α
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];
}
解决方案
You can use the following convenience constructor of the UIColor
object:
+ (UIColor *)colorWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha
这篇关于如何在Cocoa Touch中将RGB转换为HSV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!