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

后端 未结 3 1992
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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 05:51

    by the way, you get get the original background image by using function

    UIImageView *imageView = [self.navigationController.navigationBar
    backgroundImageForBarMetrics:UIBarMetricsDefault];
    

    and store the image somewhere, then you use

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

    to set it back,but most time, set to nil will solve your problem.

提交回复
热议问题