뷰 컨트롤러에서 탐색 모음의 모양 재설정 (Reset the appearance of navigation bar in a view controller)


문제 설명

뷰 컨트롤러에서 탐색 모음의 모양 재설정 (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 ThomasMahmoud Eissa)

참조 문서

  1. Reset the appearance of navigation bar in a view controller (CC BY‑SA 2.5/3.0/4.0)

#uinavigationcontroller #swift #iOS #uinavigationbar






관련 질문

세로에서 가로로 회전할 때 UIBarButtonItem 크기를 변경하는 방법은 무엇입니까? (how to change the UIBarButtonItem size when rotate from the portrait to landscape?)

performSegueWithIdentifier는 식별자 오류가 있는 segue를 생성하지 않습니다. (performSegueWithIdentifier produce no segue with identifier error)

UIAlertController는 leftBarButtonItem을 아래로 이동합니다. (UIAlertController moves leftBarButtonItem down)

현재 모달 보기는 탐색 스택에서 탐색 모음을 숨깁니다. (present modal view hides the navigation bar in navigation stack)

테이블 뷰 셀을 선택할 때 뷰 컨트롤러를 푸시할 수 없습니다. (Can't push my view controller when I select a table view cell)

프로그래밍 방식으로 탐색 컨트롤러의 초기 viewController 설정(레이어 SDK) (Set initial viewController in Navigation controller programmatically (Layer SDK))

UIViewController 유형의 표현식으로 UINavigationController를 초기화하는 호환되지 않는 포인터 유형 (Incompatible pointer types initializing UINavigationController with an expression of type UIViewController)

탐색 컨트롤러 도구 모음 크기 및 위치 - iOS Swift (Navigation Controller Toolbar Size & Location - iOS Swift)

Segue는 뒤로 막대 버튼에 데이터를 저장합니다. (Segue saves data on back bar button)

UINavigationController 푸시 전환 중 낮은 프레임 속도 (Low frame rate during UINavigationController push transition)

뷰 컨트롤러에서 탐색 모음의 모양 재설정 (Reset the appearance of navigation bar in a view controller)

탐색 모음 제목 보기 내에서 분할된 제어 스위치를 처리하려고 합니다. (Trying to handle segmented control switch inside of navigation bar title view)







코멘트