답변:
문서 에 따르면 UINavigationItem
:
self.navigationItem.setHidesBackButton(true, animated: true);
다음을 사용하는 경우 UITabBarController
:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.tabBarController?.navigationItem.hidesBackButton = true
}
빠른
// remove left buttons (in case you added some)
self.navigationItem.leftBarButtonItems = []
// hide the default back buttons
self.navigationItem.hidesBackButton = true
self.navigationItem.hidesBackButton = true
예상대로 작동합니다.
아래 코드로 시도 할 수 있습니다.
override func viewDidAppear(_ animated: Bool) {
self.navigationController?.isNavigationBarHidden = true
}
다음은 답변의 버전입니다.
// MARK: - Hiding Back Button
extension UINavigationItem {
/// A Boolean value that determines whether the back button is hidden.
///
/// When set to `true`, the back button is hidden when this navigation item
/// is the top item. This is true regardless of the value in the
/// `leftItemsSupplementBackButton` property. When set to `false`, the back button
/// is shown if it is still present. (It can be replaced by values in either
/// the `leftBarButtonItem` or `leftBarButtonItems` properties.) The default value is `false`.
@IBInspectable var hideBackButton: Bool {
get { hidesBackButton }
set { hidesBackButton = newValue }
}
}
뷰 컨트롤러의 모든 탐색 항목은 속성 관리자의 상단 섹션에이 새 속성을 갖습니다.
속성 관리자로 이동하여 탐색 막대 표시를 선택 취소하여 뒤로 버튼을 숨 깁니다.