iOS 更改tabbar字体颜色 自定义controller返回按钮

   改变系统的tabbar字体颜色:

//设置你想要显示的颜色

 NSDictionary *dictHome = [NSDictionary dictionaryWithObject:MAIN_TABBAR_COLOR forKey:NSForegroundColorAttributeName];
    [navCtr.tabBarItem setTitleTextAttributes:dictHome forState:UIControlStateSelected];
这种是单个设置, 如果想全局设置,可以这样:

    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:11], NSFontAttributeName,COLOR_NOSELETED,NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:11], NSFontAttributeName,COLOR_SELECTED,NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];

根据自己的需要,选择合适的方式进行设置;

从这篇文章中学习了: 

http://www.jianshu.com/p/e61c096753eb



如果不行使用系统的返回按,想使用自定义的按钮:

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 60, 44);

    [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];

    [button setImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateHighlighted];

    
    button.contentEdgeInsets = UIEdgeInsetsMake(0, -30, 0, 0);
    [button addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.leftBarButtonItem = item;

按钮的具体大小和位置,可以自己调整.  如果不想在每个controller里的都写,建一个父类,在父类中写这个; 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值