tabbaritemcss按钮点击高亮后高亮都是蓝色,能改成其他颜色吗

tabBarItem 设置了选择后的图片不显示颜色
| 更新于 日
设置的图片颜色是黄色的,显示出来是系统默认的蓝色,需要添加什么语句
var item2 = UITabBarItem()
item2 = self.tabBarItem
item2.selectedImage = UIImage(named: "comm_menu_ico4_hov#2x.png")
换成这个了也没有效果
var item = UITabBarController()
item.tabBarItem = self.tabBarItem
item.tabBar.selectedImageTintColor = UIColor.yellowColor()
item.tabBarItem.selectedImage = UIImage(named: "comm_menu_ico4_hov#2x.png")
item.tabBarItem.selectedImage.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
猜你喜欢:
.tintColor
@ tintColor我是在storyBoard中改的,一点效果都没有啊
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal
@ 这个也试过了
self.tabBarItem = UITabBarItem(title: "dddd", image: UIImage(named: "btn_1")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), selectedImage: UIImage(named: "btn_1_on")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal))
@ 这样还是默认的蓝色的
设置按钮图片的时候用下面这个 uiimagee分类方法
+(instancetype)originalImageName:(NSString *)name{
UIImage * image = [UIImage imageNamed:name];
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
),然后在出现的“enter code here”处贴入你的代码。
回复特定回复的时候,请点击该回复右侧的回复链接,系统将自动创建楼号和@通知。
@他人的时候注意,id后面请加一个空格。
使用左侧工具栏“贴链接”按钮()创建的优酷、土豆、youtube视频链接,将自动生成播放区域,不需要使用其他包含方式。
如果要创作长篇格式复杂的帖子,本站建议Mac用户使用,离线写好,贴入即可。如何更改为iOS的7 tabBarItems文本和图标的颜色_百度知道(注:IOS5有新的API可以实现这些功能,这里这样搞是为了支持IOS4.)
* @brief 定制的tabbar.
#import &UIKit/UIKit.h&
@interface XUTabBarController : UITabBarController
UIView * bgView4TabBar_;
#import "XUTabBarController.h"
@interface XUTabBarController()
@property(nonatomic, retain) UIView * bgView4TabB
- (void)customTabBarBackgroundC
- (void)setNoHighlightTabB
@implementation XUTabBarController
@synthesize bgView4TabBar = bgView4TabBar_;
- (void)dealloc
[bgView4TabBar_ release];
[super dealloc];
- (void)viewDidLoad
[super viewDidLoad];
[self customTabBarBackgroundColor];
- (void)viewDidUnload
[super viewDidUnload];
self.bgView4TabBar =
#pragma mark - For iPad Rotate
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
if(UIU_IsIPad)
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
CGRect frame = self.tabBar.
frame.origin.x = 0;
frame.origin.y = 0;
frame.size.width = (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
? /*横屏*/ appFrame.size.height + 20
: appFrame.size.width + 20;
self.bgView4TabBar.frame =
- (void)viewWillAppear:(BOOL)animated
[super viewWillAppear:animated];
[self willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
#pragma mark - NoHighlightTab
- (void)setSelectedIndex:(NSUInteger)index
[super setSelectedIndex:index];
[self setNoHighlightTabBar];
- (void)setSelectedViewController:(UIViewController *)selectedViewController
[super setSelectedViewController:selectedViewController];
[self setNoHighlightTabBar];
- (void)setNoHighlightTabBar
int tabCount = [self.viewControllers count] & 5 ? 5 : [self.viewControllers count];
NSArray * tabBarSubviews = [self.tabBar subviews];
for(int i = [tabBarSubviews count] - 1; i & [tabBarSubviews count] - tabCount - 1; i--)
for(UIView * v in [[tabBarSubviews objectAtIndex:i] subviews])
if(v && [NSStringFromClass([v class]) isEqualToString:@"UITabBarSelectionIndicatorView"])
{//the v is the highlight view.
[v removeFromSuperview];
#pragma mark - Custom TabBar Background Color
- (void)customTabBarBackgroundColor
///给tabbar换背景色
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
CGRect frame = self.tabBar.
frame.origin.x = 0;
frame.origin.y = 0;
frame.size.width = (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft
|| self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
? /*横屏*/ appFrame.size.height + 20
: appFrame.size.width + 20;
//bg color.
#define useTintColor 1
#if useTintColor
self.bgView4TabBar = [[[UINavigationBar alloc] initWithFrame:frame] autorelease];
((UINavigationBar *)self.bgView4TabBar).tintColor = XX_TabBgC
self.bgView4TabBar = [[[UIView alloc] initWithFrame:frame] autorelease];
self.bgView4TabBar.backgroundColor = XX_TabBgC
[self.tabBar insertSubview:self.bgView4TabBar atIndex:
self.tabBar.subviews.count - (self.viewControllers.count & 5 ? 5 : self.viewControllers.count)
阅读(...) 评论()主题 : tabBarItem改变了点击时候的图片,为什么还是默认蓝色的
级别: 侠客
可可豆: 386 CB
威望: 386 点
在线时间: 221(时)
发自: Web Page
tabBarItem改变了点击时候的图片,为什么还是默认蓝色的&&&
设置的点击后的购物车图片是黄色的,怎么让它显示出来
级别: 新手上路
可可豆: 28 CB
威望: 28 点
在线时间: 164(时)
发自: Web Page
说得太笼统了,没有图片、代码吗
级别: 侠客
可可豆: 386 CB
威望: 386 点
在线时间: 221(时)
发自: Web Page
回 1楼(gs01md) 的帖子
var item = UITabBarController()&&&&&&&&&&&&&&&&item.tabBarItem = self.tabBarItem&&&&&&&&&&&&&&&&item.tabBar.selectedImageTintColor = UIColor.yellowColor()&&&&&&&&&&&&&&&&item.tabBarItem.selectedImage = UIImage(named: &&)&&&&&&&&&&&&&&&&item.tabBarItem.selectedImage.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
图片:FF7-.png
级别: 新手上路
UID: 301881
可可豆: 892 CB
威望: 507 点
在线时间: 907(时)
发自: Web Page
系统风格默认是蓝色
级别: 新手上路
可可豆: 3 CB
威望: 3 点
在线时间: 91(时)
发自: Web Page
item.tabBar.translucent =item.tabBar.tintColor = UIColor.yellowColor()  选中色item.tabBar.barTintColor = 背景色
图片:6DF44CD9-0E4E-32B185DC26.png
级别: 侠客
可可豆: 386 CB
威望: 386 点
在线时间: 221(时)
发自: Web Page
回 4楼(zlisgood1) 的帖子
我的还是没效果
级别: 新手上路
UID: 421055
可可豆: 27 CB
威望: 15 点
在线时间: 56(时)
发自: Web Page
回 5楼(kuqiqi) 的帖子
级别: 新手上路
可可豆: 10 CB
威望: 10 点
在线时间: 115(时)
发自: Web Page
selectedImage: UIImage(named: &first_press&)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)&&加上这个,意思是设置它的渲染模式
级别: 新手上路
可可豆: 22 CB
威望: 22 点
在线时间: 50(时)
发自: Web Page
你是家在了全局的吗
关注本帖(如果有新回复会站内信通知您)
苹果公司现任CEO是谁?2字 正确答案:库克
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版}

我要回帖

更多关于 setitemstate 不高亮 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信