我在一个项目中需要同时创建自定义 UINavigationBar
和 UITabBar
。
我的问题在于元素的颜色(淡色!)。
我不希望我的元素有任何色调。我试图把它变成清晰的颜色,但这只会让它消失(它变得透明)。
所以,概括地说,我有自己的酒吧项目图像,并且每个图像都包含自己特定的颜色。我读过,为了做我想做的事,我必须子类化我的 UIBar
,但我没有得到比这更多的信息。我应该在我的子类中修改什么以摆脱该色调颜色约束?谢谢。
编辑: 色调颜色不应用于项目,而是应用于栏(因此所有项目)。所以我的问题是我想要我的元素的特定颜色
编辑 2:
好的,我想我明白了!解决方案是使用 UIBarButtonItem
方法:initWithCustomView:
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.bounds = CGRectMake( 0, 0, 26, 26);
[backBtn setImage:[UIImage imageNamed:@"BackBtn.png"] forState:UIControlStateNormal];
[backBtn addTarget:self.navigationController action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = item;
但这只适用于 UINavigationBar
,因为它需要 UIBarButtonItem
。另一方面,UITabBar
只采用 UITabBarItem
,它不符合 initWithCustomView
。所以我仍然在那里泡菜......
最佳答案
前段时间有人问过这个问题,但我在谷歌上找到了,所以其他人也可能找到它:)
答案就是用这个方法
UITabBarItem(title:, image:, selectedImage:)
打开始终原始渲染模式的图像
image.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
希望对您有所帮助!
关于ios - 自定义 iOS UINavigationBar/UITabBar 和移除 Tint Colors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21455355/