作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我浏览了所有典型的导航栏 tintcolor 教程和问题。我为导航栏设置了色调,但我有一个邮件图标,当有邮件时需要更改为自定义颜色。 (如 reddit 橙色邮件图标)
我只能在使用系统 UIColors 时正确设置色调。
self.leftNavigationBarButton = [[UIBarButtonItem alloc] initWithImage:someImage style:UIBarButtonItemStylePlain target:self action:@selector(foo:)];
self.navigationItem.leftBarButtonItem = self.leftNavigationBarButton;
self.leftNavigationBarButton.tintcolor = [UIColor redColor];
但是,如果我随后使用自定义颜色。
self.leftNavigationBarButton.tintcolor = [UIColor colorWithRed:100 green:40 blue:20 alpha:1.0];
它使图标变白。有谁知道发生了什么或我如何使用自定义颜色?
最佳答案
我从这个答案中弄明白了https://stackoverflow.com/a/5642229/1732711 .
简短的回答是将 RGB 值除以 255.0。
self.leftNavigationBarButton.tintcolor = [UIColor colorWithRed:100/255.0 green:40/255.0 blue:20/255.0 alpha:1.0];
关于ios - 如何将 UIBarButtonItem tintcolor 设置为非默认 UIColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29177064/
我是一名优秀的程序员,十分优秀!