문제 설명
뷰 컨트롤러에서 탐색 모음의 모양 재설정 (Reset the appearance of navigation bar in a view controller)
다음을 사용하여 탐색 모음의 하단 경계선(그림자 이미지)을 비활성화했습니다.
self.navigationController.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationController.navigationBar.shadowImage = UIImage()
하지만 기기를 잠그고 다시 잠금을 해제하면 하단 경계선이 나타납니다. viewWillAppear:
에서 위의 코드를 사용하여 다시 숨길 수 있었습니다.하지만 탐색 모음이 나타날 때마다 기본 구성으로 재설정되는 원인을 알고 싶습니다. ?
아래 코드를 사용하여 그림자 선을 다른 ViewController에 다시 표시하도록 불가능하기 때문에:
self.navigationController.navigationBar.setBackgroundImage(nil, for: .default)
self.navigationController.navigationBar.shadowImage = nil
탐색을 재설정하는 방법을 알고 싶습니다. 하단 경계선(그림자 이미지)이 다시 나타나게 하는 막대 모양은?
참조 솔루션
방법 1:
Unlocking device will NOT call viewWillAppear, May be you are using a BaseViewController with adding Notification Observer on UIApplicationDidBecomeActiveNotification
Try using Appearance instead on AppDelegate
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
UINavigationBar.appearance().shadowImage = UIImage()
And Reappear the line again
self.navigationController?.navigationBar.setBackgroundImage(nil, for: .default)
self.navigationController?.navigationBar.shadowImage = nil
(by Tibin Thomas、Mahmoud Eissa)