zoukankan      html  css  js  c++  java
  • 导航栏的坑 (导航透明/导航除线/titleIView)

    //以下四个条件缺一不可
    
    /1.必须是半透明状态
    self.navigationBar.translucent = YES;
    //2.导航栏背景图片为空图片 (不可以设置backgroundColor或者barTintColor, 没有效果的)
    [self.navigationBar setBackgroundImage:[[UIImage alloc]init] forBarMetrics: UIBarMetricsDefault];
    //3.阴影图片为空图片 (不可以设置为nil,没用的)
    [self.navigationBar setShadowImage:[[UIImage alloc] init]];
    
    //其实到导航栏才44px, 但是backgroundView有64px 
    self.navigationBar.layer.masksToBounds = YES;

    导航除线

    self.navigationController.navigationBar.translucent = NO;
        self.navigationController.navigationBar.shadowImage = [UIImage new];
        UIImage *img = [UIImage imageWithColor:[UIColor greenColor] size:CGSizeMake(100, 100)];
    //必须设置一张图片而不是设置背景颜色
        [self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];

    3.设置设置titleView时, titleView的宽度和高度无法自由设置

    设置搜索案例

    如果已经设置了默认返回的图标, 你会发现设置titleview时, 你的titleview左边会空出一块

    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 500, 30)];
        UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:tf];
        self.navigationItem.leftBarButtonItem = item;
  • 相关阅读:
    【模板】Sparse-Table
    UVa 11235 Frequent values
    【模板】树状数组
    UVa 1428 Ping pong
    数学技巧
    UVa 11300 Spreading the Wealth
    UVa 11729 Commando War
    UVa 11292 Dragon of Loowater
    POJ 3627 Bookshelf
    POJ 1056 IMMEDIATE DECODABILITY
  • 原文地址:https://www.cnblogs.com/apem/p/5254389.html
Copyright © 2011-2022 走看看