[Swift/iOS]UI Tab bar code memo
https://velog.io/@j00hyun/3.8-Tab-Bar-Controllers
var stackedLayoutAppearance: UITabBarItemAppearance
The 3 UITabBarItemAppearances
Right around the 8 minute mark in the WWDC video, apple mentions there are 3 different appearances for UITabBarAppearance:
- stackedLayoutAppearance – This appears to be the standard appearance
- inlineLayoutAppearance – “Which you’ll see on iPads”
- compactInlineLayoutAppearance – “Which you’ll see on smaller phones”
These 3 appearance are used differently than the ones for UINavigationViewAppearance. They’re a property of the StandardAppearance, not of a UITabBar. To update them, you do something like:
https://schwiftyui.com/swiftui/customizing-your-tabviews-bar-in-swiftui/
Customizing your TabView's Bar in SwiftUI - SchwiftyUI
In my last post, I went over customizing your NavigationView’s bar using the UINavigationBarAppearance API. Considering how similar a NavigationView and TabView are, it seems only natural to talk about customizing your TabBar using UIAppearance and UITab
schwiftyui.com
let calendarVC = CalendarViewController()
let diaryVC = UINavigationController(rootViewController: DiaryViewController())
let dataVC = DataViewController()
let tabBarController = UITabBarController()
tabBarController.setViewControllers([calendarVC, diaryVC, dataVC], animated: true)
if let items = tabBarController.tabBar.items {
items[0].title = "Calendar"
items[0].image = UIImage(systemName: "calendar.circle")
items[0].selectedImage = UIImage(systemName: "calendar.circle.fill")
items[1].title = "Diary"
items[1].image = UIImage(systemName: "pencil.circle")
items[1].selectedImage = UIImage(systemName: "pencil.circle.fill")
items[2].title = "Data"
items[2].image = UIImage(systemName: "square.and.arrow.down.on.square")
items[2].selectedImage = UIImage(systemName: "square.and.arrow.down.on.square.fill")
}
UITabBar.appearance().backgroundColor = .black // 배경
UITabBar.appearance().tintColor = .white // 선택됐을 때 색
UITabBar.appearance().unselectedItemTintColor = .systemGray
window?.rootViewController = tabBarController
window?.makeKeyAndVisible()