Objective c 为什么我不能使用自己的UIColor来更改uitabarite';什么是标题颜色?

Objective c 为什么我不能使用自己的UIColor来更改uitabarite';什么是标题颜色?,objective-c,uicolor,Objective C,Uicolor,我尝试将Uitabritem标题的颜色使用方法设置为: UIColor *sColor = [UIColor colorWithRed:1/255.0 green:161/255.0 blue:171/255.0]; UITabBarItem *b_item = [[UITabBarItem alloc] initWithTitle:@"test" image:normal_image selectedImage:selected_image]; [b_item setTitleTextAttr

我尝试将Uitabritem标题的颜色使用方法设置为:

UIColor *sColor = [UIColor colorWithRed:1/255.0 green:161/255.0 blue:171/255.0];
UITabBarItem *b_item = [[UITabBarItem alloc] initWithTitle:@"test" image:normal_image selectedImage:selected_image];
[b_item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:sColor, NSForegroundColorAttributeName, [UIFont systemFontOfSize:13], NSFontAttributeName, nil] forState:UIControlStateSelected];
但一旦我更改代码,这些代码就毫无意义了:

UIColor *sColor = [UIColor colorWithRed:1/255.0 green:161/255.0 blue:171/255.0];
在这些代码中:

UIColor *sColor = [UIColor redColor];
这个代码是有效的。 我不知道为什么我不能使用自己定义的颜色值。请给我一些帮助

在末尾添加alpha:1.0

[UIColor colorWithRed:1/255.0 green:161/255.0 blue:171/255.0 alpha:1.0];

尝试向方法中添加alpha,如下所示:

UIColor *sColor = [UIColor colorWithRed:1/255.0 green:161/255.0 blue:171/255.0 alpha:1.0];
根据用户评论修改答案

如果不是阿尔法,那么可能是你设置巴布托图案颜色的方式

[[UITabBarItem appearance] setTitleTextAttributes:@{
    NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:13.0f],                                                         
    NSForegroundColorAttributeName : [UIColor colorWithRed:1/255.0 green:161/255.0 blue:171/255.0 alpha:1]
    } forState:UIControlStateNormal];

注意,我已将forState设置为UIControlStateNormal。在您的问题中,它是UIControlStateSelected,仅当用户选择按钮时才起作用。

UIColor不带alpha。。。如何运行此代码??[UIColor COLOR WITHRED:1.0/255.0绿色:161.0/255.0蓝色:171.0/255.0 alpha:1.0];对不起,我在我的问题中取消了alpha值,事实上我设置了alpha值,但它不起作用。我已经修改了我的答案。我希望它有帮助。我想做的是,一旦用户选择了UITabBarItem的标题,将其颜色更改为不同的颜色,因此我设置了uicontrol StateSelected…。无论如何,感谢您的回答。我想一定还有其他需要更改的内容,我将尝试找到其他解决方案。非常感谢,我在我的问题中取消了alpha值,事实上我设置了alpha值,但它就是不起作用。