zoukankan      html  css  js  c++  java
  • ios7 导航栏适配

    ios ui开发过程中,经常会使用到导航栏,默认的样式比较单一,所以经常需要修改导航栏的样式

    ios4:

    - (void)drawRect:(CGRect)rect {
        UIImage *image = [UIImage imageNamed:@"navbar_bg.png"];
        [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
        return;
    }
    

     ios5以后:

     if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
    {   [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar_bg.png"] forBarMetrics:UIBarMetricsDefault]; }

    ios7,由于导航条会扩展到系统状态栏上面,所以图片高度需要增加20px,如果没有另外处理可能会出现状态栏黑条

            if (7.0 <= [[[UIDevice currentDevice] systemVersion] floatValue])
            {
                [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar_bg_7.png"] forBarMetrics:UIBarMetricsDefault];
    
            }
            else
            {
                [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navbar_bg.png"] forBarMetrics:UIBarMetricsDefault];
            }
    
  • 相关阅读:
    goreplay~基本知识
    goreplay~http输出队列
    goreplay~拦截器设置
    goreplay~流量变速
    goreplay~http过滤参数
    goreplay~文件输出解析
    goreplay~http输出工作线程
    Antlr4 语法解析器(下)
    2021最新版Eclipse的下载和使用
    MySQL中drop、truncate和delete的区别
  • 原文地址:https://www.cnblogs.com/geweb/p/navigationBarBG.html
Copyright © 2011-2022 走看看