美文网首页Xcode 代码片段
导航控制器全透明

导航控制器全透明

作者: _YN | 来源:发表于2018-12-10 14:43 被阅读0次

OC

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

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

Swift

override func viewWillAppear(_ animated: Bool) {        self.navigationController?.navigationBar .setBackgroundImage(nil, for: UIBarMetrics.default)            self.navigationController?.navigationBar.shadowImage = UIImage()    }

override func viewDidAppear(_ animated: Bool) {        self.navigationController?.navigationBar .setBackgroundImage(UIImage(), for: UIBarMetrics.default)        self.navigationController?.navigationBar.shadowImage = UIImage()    }

[如果您在阅读我的文章时有疑问 , 请点击这里](https://www.jianshu.com/p/1e68be1e6646)

相关文章

网友评论

    本文标题:导航控制器全透明

    本文链接:https://www.haomeiwen.com/subject/qdgrhqtx.html