Restore navigationBar background image after setting it to [UIImage new]

后端 未结 3 2077
Happy的楠姐
Happy的楠姐 2021-02-01 05:04

I needed a completely transparent navigation bar for the mapView so I did this:

[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarM         


        
3条回答
  •  终归单人心
    2021-02-01 05:48

    Set nil for image of navigation Controller on viewWillDisappear on map view

    Set this two method in your mapview

    MapView.m

    -(void)viewWillAppear:(BOOL)animated{
        [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
        [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    }
    
    -(void)viewWillDisappear:(BOOL)animated{
        [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
        [self.navigationController.navigationBar setShadowImage:nil];
    }
    

提交回复
热议问题