zoukankan      html  css  js  c++  java
  • iOS-系统自带navigationController-最全设置

     

        // 导航栏背景色

        self.navigationController.navigationBar.barTintColor = [UIColor orangeColor];

        // 设置push出来的controller返回按钮的箭头颜色

        [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

        

        // 设置push出来的controller返回按钮字体及颜色

        UIBarButtonItem *backItem=[[UIBarButtonItem alloc]init];

        backItem.title=@"BBBACK";

        [backItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateNormal];

        self.navigationItem.backBarButtonItem = backItem;

        

        // 设置当前导航栏左右barbutton

        UIBarButtonItem *leftBarbutton = [[UIBarButtonItem alloc] initWithTitle:@"左按钮" style:UIBarButtonItemStylePlain target:self action:@selector(action:)];

        [leftBarbutton setTintColor:[UIColor blackColor]];

        [leftBarbutton setImage:[UIImage imageNamed:@"icon57.png"]];

        [leftBarbutton setTag:110];

        

        UIBarButtonItem *rightBartutton = [[UIBarButtonItem alloc] initWithTitle:@"右按钮" style:UIBarButtonItemStylePlain target:self action:@selector(action:)];

        [rightBartutton setTag:111];

        [rightBartutton setTintColor:[UIColor whiteColor]];

     

        self.navigationItem.rightBarButtonItem= rightBartutton;

        self.navigationItem.leftBarButtonItem = leftBarbutton;

        

        // 导航栏文字颜色

        //UIView *navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 50, 30)];

        //[navView setBackgroundColor:[UIColor whiteColor]];

        //[self.navigationItem setTitleView:navView];

        [self.navigationItem setTitle:@"主页"];

        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]}];

       

        // 视图坐标从导航栏高度开始

        [self.navigationController.navigationBar setTranslucent:NO];

     

        // 添加一个导航栏

        UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 70)];

        UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle:@"首页"];

        [navigationBar pushNavigationItem:navigationItem animated:NO];

        UIBarButtonItem *pushBarButton = [[UIBarButtonItem alloc] initWithTitle:@"左按钮" style:UIBarButtonItemStylePlain target:self action:@selector(push:)];

        [pushBarButton setTintColor:[UIColor blackColor]];

        [pushBarButton setImage:[UIImage imageNamed:@"icon57.png"]];

        navigationItem.rightBarButtonItem = pushBarButton;

        [self.view addSubview:navigationBar];

        // 设置其字体颜色和背景色

        [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]}];

        [[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];

  • 相关阅读:
    使用littleTools简化docker/kubectl的命令
    (上)python3 selenium3 从框架实现学习selenium让你事半功倍
    一篇文教你使用python Turtle库画出“精美碎花小清新风格树”快来拿代码!
    VxLAN协议详解
    深入理解大数据之——事务及其ACID特性
    深入理解大数据架构之——Lambda架构
    JQCloud: 一个前端生成美化标签云的简单JQuery插件
    详解Java中的final关键字
    OpenDaylight虚拟租户网络(VTN)详解及开发环境搭建
    使用Pelican在Github(国外线路访问)和Coding(国内线路访问)同步托管博客
  • 原文地址:https://www.cnblogs.com/XHShare/p/4920400.html
Copyright © 2011-2022 走看看