How to remove border of the navigationBar in swift?

前端 未结 25 2094
执笔经年
执笔经年 2020-12-02 04:41

i\'ve been trying to remove the navigationBars border without luck. I\'ve researched and people seem to tell to set shadowImage and BackgroundImage to nil, but this does not

25条回答
  •  孤街浪徒
    2020-12-02 05:26

    in your custom navigationController add these lines:

    self.navigationBar.setBackgroundImage(UIImage(), for:.default)
    self.navigationBar.shadowImage = UIImage()
    self.navigationBar.layoutIfNeeded()
    

    Important Note

    the last line is important if you use the first line viewDidLoad() method because navigationController should redraw nav bar but easily you can use this without layoutIfNeeded() in the viewWillAppear() method before it draws the nav bar

提交回复
热议问题