我必须将ffe1b1的标题颜色设置为UIButton.RGB值为ffe1b1为255,225,177。 我正在尝试这个代码,但它没有正确反映。我在网上搜索颜色组件是介于0.0和1.0之间的浮点数! 那么什么是给出RGB值的正确方法。谢谢
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom] ;
btn.frame = CGRectMake(134.0, 193.0, 80.0, 30.0);
[btn setBackgroundImage:img forState:UIControlStateNormal];
[btn setTitle:@"Contact" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor colorWithRed:255.0 green:225.0 blue:177.0 alpha:0.6 ]forState: UIControlStateNormal];
答案 0 :(得分:10)
更改此行
[btn setTitleColor:[UIColor colorWithRed:255.0 green:225.0 blue:177.0 alpha:0.6 ]forState: UIControlStateNormal];
到
[btn setTitleColor:[UIColor colorWithRed:(255.0/255) green:(225.0/255) blue:(177.0/255) alpha:0.6 ]forState: UIControlStateNormal];
答案 1 :(得分:2)
在目标c中,您无法直接使用RGB值。点击此链接: http://www.touch-code-magazine.com/web-color-to-uicolor-convertor/