Swift

Swift - Tab Bar ์™„์ „ํžˆ ์ˆจ๊ธฐ๊ธฐ(hidesBottomBarWhenPushed ์†์„ฑ)

iosos 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