如何将mystring转换为UIcolor类型,以便我可以使用tableview中的所选颜色更改标签颜色?

时间:2014-06-04 13:03:29

标签: ios objective-c uicolor

 [self performSelector:@selector(afterClick:) withObject:[UIColor redColor]];

-(void)afterClick:(UIColor *)viewColor{
    lblColor.backgroundColor=viewColor;

}

我想传递字符串而不是UIColor,请建议

1 个答案:

答案 0 :(得分:0)

#define UICOLOR_FROM_HEX(hex, alpha) [UIColor colorWithRed: ((float)((hex & 0xFF0000) >> 16))/255.0 green: ((float)((hex & 0xFF00) >> 8))/255.0 blue: ((float)(hex & 0xFF))/255.0 alpha: alpha]

使用:

self.backgroundColor = UICOLOR_FROM_HEX(0xFFEECC, 1.0);