Swift

Swift - Tab Bar 완전히 숨기기(hidesBottomBarWhenPushed 속성)

Goniii 2024. 11. 11. 16:53

📑 학습 내용

  • homeVC에서 navigationController로 다른 뷰로 넘어갈 때, 탭 바가 완전히 사라지지 않음 뷰는 나타나지 않지만, 레이아웃은 그대로 유지되는 현상 발생
  • tabBarController?.tabBar.isHidden = true 사용시

  • ViewController의 hidesBottomBarWhenPushed 속성으로 탭 바를 완전히 숨길 수 있음
    • nextVC.hidesBottomBarWhenPushed = true

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        switch collectionView {
        case homeView.justDropCollectionView :
            let nextVC = DetailViewController()
            nextVC.hidesBottomBarWhenPushed = true
            navigationController?.pushViewController(nextVC, animated: true)
        default:
            let nextVC = DetailViewController()
            navigationController?.pushViewController(nextVC, animated: true)
        }
    }

📚 참고 자료

 

hidesBottomBarWhenPushed | Apple Developer Documentation

A Boolean value indicating whether the toolbar at the bottom of the screen is hidden when the view controller is pushed on to a navigation controller.

developer.apple.com