zoukankan      html  css  js  c++  java
  • iOS开发之--如何修改TabBarItem的title的字体和颜色/BarButtonItem的title的字体大小和颜色/添加背景图片,并添加点击方法

    在进行项目的过程中,我们往往会遇到各种各样的自定义颜色和字体,下面提供一种修改系统自带的TabBarItem的字体和颜色的方法,希望能帮到大家:

    [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:  
                                                           [UIColor whiteColor], UITextAttributeTextColor,  
                                                           nil] forState:UIControlStateNormal];  
       UIColor *titleHighlightedColor = [UIColor greenColor];  
       [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:  
                                                           titleHighlightedColor, UITextAttributeTextColor,  
                                                           nil] forState:UIControlStateSelected];

    上面是正常的,下面是选中的!

    BarButtonItem的title的字体大小和颜色:

    [button1 setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateNormal];
        [button1 setTitle:@"排单币转账记录"];
        [button1 setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} forState:UIControlStateNormal];
        self.navigationItem.rightBarButtonItem = button1;

    这样也可以修改大小!

    UIBarButtonItem的添加返回背景图片和点击方法:

    UIBarButtonItem *button = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"backBarButton"] style:(UIBarButtonItemStyleDone) target:self action:@selector(backAction)];
        self.navigationItem.leftBarButtonItem = button;

    以上只是修改系统的,可能有些方法我们遇不到用的机会!如果是自定义的话,就不用这么麻烦了!

  • 相关阅读:
    win10如何安装应用商店
    Redis从入门到精通——认识 Redis
    SkyWalking——SkyWalking安装和配置
    SkyWalking——SkyWalking二次开发必备知识
    SkyWalking——SkyWalking架构设计
    SkyWalking——全面认识Apache SkyWalking
    Redis从入门到精通——初识NoSQL
    RocketMQ(4.8.0)——延迟消息机制
    RocketMQ(4.8.0)——事务消息机制
    RocketMQ(4.8.0)——Broker 的关机恢复机制
  • 原文地址:https://www.cnblogs.com/hero11223/p/5972443.html
Copyright © 2011-2022 走看看