• 导航条、状态条高亮状态改变


    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
        RootViewController*root=[[RootViewController alloc]init];
        UINavigationController*nav=[[UINavigationController alloc]initWithRootViewController:root];
        
        //[[UINavigationBar appearance]setTintColor:[UIColor redColor]];
        //ios 7以后使用BarTintColor 改变导航栏的背景颜色
        //  [[UINavigationBar appearance]setBarTintColor:[UIColor cyanColor]];
        
        [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0x067AB5)];
    
        
        //设置图片
        //[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"u27.png"] forBarMetrics:UIBarMetricsDefault];
        //导航条上跳转之后的  返回字体的颜色
        [[UINavigationBar appearance] setTintColor:[UIColor redColor]];
        
     
        [[UINavigationBar appearance] setTranslucent:YES];
        
        self.window.rootViewController=nav;
        //状态条变成高亮的(白色)
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
        //状态条隐藏
        //  [UIApplication sharedApplication].statusBarHidden=YES;
        //导航条隐藏
        //  [self.navigationController setNavigationBarHidden:YES];
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    //或者在info .plist中添加一个key   View controller-based status bar appearance并将它改成 NO;  ----设置成高亮状态
    //在info .plist中添加一个key   Status bar is initially hidden 将他改为YES 就能隐藏状态栏(启动app以后的所有的状态栏)
    #import "RootViewController.h"
    #import "nextViewController.h"
    #define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
    @interface RootViewController ()
    {
        nextViewController*next;
    }
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        next=[[nextViewController alloc]init];
        UIButton*btn=[UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame=CGRectMake(30, 30, 30, 30);
        btn.backgroundColor=[UIColor blackColor];
        [btn addTarget:self action:@selector(pressBtn) forControlEvents:UIControlEventTouchUpInside];
        [btn setImage:[UIImage imageNamed:@"u2.png"] forState:UIControlStateNormal];
       self.navigationItem.title=@"test";
      //  [self.navigationItem setTitle:@"ssss"];  都行
        //改变标题栏字体的大小和颜色
        //也可以创建一个label  把label 添加到导航条上,然后设置透明度
        [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
        
        UIBarButtonItem*item=[[UIBarButtonItem alloc]initWithCustomView:btn];
        self.navigationItem.leftBarButtonItem=item;
        //导航条隐藏
      //  [self.navigationController setNavigationBarHidden:YES];
        //[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
    }
    -(void)viewWillAppear:(BOOL)animated
    {
        //不同界面的导航条颜色变化
       // self.navigationController.navigationBar.translucent=YES;
        self.navigationController.navigationBar.barTintColor = [UIColor greenColor];
    }
    -(void)pressBtn
    {
        [self.navigationController pushViewController:next animated:YES];
    }
    #import "nextViewController.h"
    
    @interface nextViewController ()
    
    @end
    
    @implementation nextViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
    }
    -(void)viewWillAppear:(BOOL)animated
    {
        //不同界面的导航条颜色变化
       // self.navigationController.navigationBar.translucent=YES;
        self.navigationController.navigationBar.barTintColor = [UIColor cyanColor];
        
        
    }

  • 相关阅读:
    CommonJS和AMD/CMD
    map 有{}的时候需要有return 没有{}的时候不需要有return
    sublime3添加插件
    C++—模板(1)模板与函数模板
    函数的调用过程(栈帧)
    Linux-进程描述(5)之进程环境
    Linux-进程描述(4)之进程优先级与进程创建执行
    多态(2)纯虚函数与重载、重写(覆盖)、重定义(隐藏)
    多态(1)静态多态与动态多态以及虚函数相关
    Linux-进程描述(3)之进程状态僵尸进程与孤儿进程
  • 原文地址:https://www.cnblogs.com/sayimba/p/5697950.html
Copyright © 2020-2023  润新知