iOS Swift 맵 라이브러리 요약 UITObBar·UITObBarItem 편

설계


TabBar의 선을 지웁니다.

tabBar.shadowImage = UIImage()

TabBar 색상 변경

tabBar.barTintColor = UIColor.blue

TabBarItem 선택 색상 변경

tabBar.tintColor = UIColor.purple

TabBarItem의 비선택 색상 변경(iOS 10.0 이후)

tabBar.unselectedItemTintColor = UIColor.white

배치 표시

// 一つ目のタブにバッヂを表示
tabBar.items!.first?.badgeValue = "バッヂ"

일괄 색상 변경

tabBar.items!.first?.badgeColor = UIColor.purple

나타내다


TabBarController 표시

let firstVC = UIViewController()
firstVC.view.backgroundColor = UIColor.orange
firstVC.tabBarItem = UITabBarItem(tabBarSystemItem: .bookmarks, tag: 1)

let secondVC = UIViewController()
secondVC.view.backgroundColor = UIColor.blue
secondVC.tabBarItem = UITabBarItem(tabBarSystemItem: .downloads, tag: 2)

let tabBarController = UITabBarController()
tabBarController.setViewControllers([firstVC, secondVC], animated: false)
present(tabBarController, animated: true, completion: nil)

조작하다


tabBarController?.selectedIndex = 2

탭을 눌렀을 때 모드 보이기

class TabViewController: UITabBarController, UITabBarControllerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.delegate = self
    }

    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        /// 
        if viewController is タブに設定されているViewControllerのClassを指定 {
            let modalVC = UIViewController()
            modalVC.view.backgroundColor = UIColor.purple
            present(modalVC, animated: true, completion: nil)
            return false
        }
        return true
    }
}

navigationController에서 push할 때 TabBar 숨기기

hidesBottomBarWhenPushed = true

프로그램 라이브러리


TabBarItem 애니메이션 벌크 디스플레이, 범례 디스플레이, 기타 사용자 정의


eggswift/ESTabBarController



TabBarItem 애니메이션


Ramotion/animated-tab-bar

위 첨자 TabBar(1)


KrishnaPatell/KPSmartTabBar

위 첨자 TabBar(2)


xmartlabs/XLPagerTabStrip

위 첨자 TabBar(3)


EndouMari/TabPageViewController

태그 시리즈

  • UITABar·UITABarItem 편
  • UINaviationBar·UIBARButton Item 편
  • 좋은 웹페이지 즐겨찾기