iOS 设置导航透明

- (void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];

    [self.navigationController.navigationBar setBackgroundImage:[UIImage new]forBarMetrics:UIBarMetricsDefault];

    //去掉导航栏底部的黑线

     self.navigationController.navigationBar.shadowImage = [UIImage new];

    

}

- (void)viewWillDisappear:(BOOL)animated{

    [super viewWillDisappear:animated];

    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];

    [self.navigationController.navigationBar setShadowImage:nil];

    

}

 

 

//给导航条设置一个空的背景图 使其透明化

    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];

    //去除导航条透明后导航条下的黑线

    [self.navigationController.navigationBar setShadowImage:[UIImage new]];

 

//全局设置

 

- (void)viewDidLoad {

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    // 2.滑动返回手势

    self.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;

    //修改返回按钮的颜色

    self.navigationBar.tintColor = [UIColor orangeColor];

    //导航控制器标题的颜色

   // [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor]}];

    self.navigationBar.translucent = NO;

    //  去除导航条底部线

    [[UINavigationBar appearance] setBackgroundImage:[self createImageWithColor:[UIColor orangeColor]] forBarMetrics:UIBarMetricsDefault];

    [[UINavigationBar appearance] setShadowImage:[self createImageWithColor:[UIColor blueColor]]];

    //[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)

                                                         //forBarMetrics:UIBarMetricsDefault]

    //self.navigationBar.topItem.title = @"";

    

    // [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, 0) forBarMetrics:UIBarMetricsDefault];

    

    [[UINavigationBar appearance] setTitleTextAttributes:

     @{NSFontAttributeName:[UIFont systemFontOfSize:20],

       NSForegroundColorAttributeName:[UIColor greenColor]}];

    

}

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值