我想改变UILabel文本的颜色,但是我不能改变颜色,这就是我的代码的样子。
UILabel *categoryTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 46, 16)];
categoryTitle.text = @"abc";
categoryTitle.backgroundColor = [UIColor clearColor];
categoryTitle.font = [UIFont systemFontOfSize:12];
categoryTitle.textAlignment = UITextAlignmentCenter;
categoryTitle.adjustsFontSizeToFitWidth = YES;
categoryTitle.textColor = [UIColor colorWithRed:188 green:149 blue:88 alpha:1.0];
[self.view addSubview:categoryTitle];
[categoryTitle release];
标签文本颜色是白色,而不是我的自定义颜色。
谢谢你的帮助。
发布于 2013-06-01 20:25:38
也许更好的方法是
UIColor *color = [UIColor greenColor];
[self.myLabel setTextColor:color];
这样我们就有了彩色文本
发布于 2015-05-18 22:26:31
试试这个,其中alpha是不透明的,其他的是红色,绿色,蓝色的香奈儿-
self.statusTextLabel.textColor = [UIColor colorWithRed:(233/255.f) green:(138/255.f) blue:(36/255.f) alpha:1];
发布于 2014-07-03 14:45:57
这是可能的,它们在InterfaceBuilder中没有连接。
文本颜色(colorWithRed:(188/255) green:(149/255) blue:(88/255))
是正确的,可能是连接中的错误,
background colour用于标签的背景色,textcolor用于属性textcolor。
https://stackoverflow.com/questions/2532409
复制相似问题