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

  • 相关阅读:
    Android Studio没有 Build Bundle(s)/Apk(s)选项或者Make Project没有反应
    typescript遍历Map
    Cocos Creator的项目优化问题
    Cocos Creator 常用优化技巧汇总
    CocosCreator客户端优化系列(四):CPU占用以及性能优化
    CocosCreator客户端优化系列(三):内存优化
    CocosCreator客户端优化系列(二):渲染优化
    CocosCreator客户端优化系列(一):加载优化(下)
    CocosCreator客户端优化系列(一):加载优化(上)
    cocos creator性能优化--Prefab加载优化
  • 原文地址:https://www.cnblogs.com/XHShare/p/4920400.html
Copyright © 2020-2023  润新知