1, 頁(yè)面加載完畢即將顯示時(shí), 保存當(dāng)前NavigationBar及其分割線的背景圖片, 并分別設(shè)置其背景圖片為新創(chuàng)建空白圖片
overridefuncviewWillAppear(_animated:Bool) {
? ? ? ? super.viewWillAppear(animated)
? ? ? ? naviBarBgImage = navigationController?.navigationBar.backgroundImage(for: .default)
? ? ? ? navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
? ? ? ? naviBarBgShadowImage = navigationController?.navigationBar.shadowImage
? ? ? ? navigationController?.navigationBar.shadowImage = UIImage()
? ? }
2, 在頁(yè)面即將消失時(shí), 還原其背景圖片
overridefuncviewWillDisappear(_animated:Bool) {
? ? ? ? super.viewWillDisappear(animated)
? ? ? ? navigationController?.navigationBar.setBackgroundImage(naviBarBgImage, for: .default)
? ? ? ? navigationController?.navigationBar.shadowImage = naviBarBgShadowImage
? ? }