これが私の TabView です:
struct HomeView: View {
let auth: UserAuth
init(auth: UserAuth) {
self.auth = auth
UITabBar.appearance().barTintColor = UIColor(named: "CustomOrange")
UITabBar.appearance().unselectedItemTintColor = UIColor.white.withAlphaComponent(0.6)
UITabBar.appearance().autoresizesSubviews = true
UITabBar.appearance().backgroundColor = UIColor(named: "CustomOrange")
}
var body: some View {
ZStack {
TabView(selection: $selectedTab) {
Settings(auth: auth)
.tabItem {
Image(systemName: "gear")
Text("Settings")
}.tag(0)
タブビュー バーの色をカスタム オレンジに設定した場合:
UITabBar.Appearance().barTintColor = UIColor(名前: "CustomOrange")
常にデフォルトのシステムオレンジ (Color.orange と同等) になります
私のカスタム オレンジは #ff8000 です。
タブバーの色はシステムカラーに制限されていますか?
------------------------
Xcode 12 / iOS 14 では正常に動作します。これは、色合い (純粋ではない) の色です (結果をテストするためにピッカーを使用した場合)。純粋な色を割り当てるには、半透明を無効にする必要があります
UITabBar.appearance().isTranslucent = false
0