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]];

  • 相关阅读:
    minicom使用
    Oracle(+)号用法
    金蝶AAS对HTTP方法有限制
    Maven设置utf8编码格式
    ELK实时日志分析平台环境部署--完整记录(ElasticSearch+Logstash+Kibana )
    Redis中的持久化操作
    iOS 动画Animation
    iOS打造属于自己的用户行为统计系统
    WEB前端,混合排版,有的宽有的窄,滚动会出现空白处,怎么办。
    hadoop云盘client的设计与实现(一)
  • 原文地址:https://www.cnblogs.com/XHShare/p/4920400.html
Copyright © 2011-2022 走看看