0

ライト/ダーク モードのカスタム カラー アセットを使用する iOS 14.2 で実行されている MacOS 11.01 の Xcode 12.2 に SwiftUI 5.3 マルチプラットフォーム アプリがあります。アプリを起動すると、ライトモードとダークモードが交互に完全に機能します。それに応じてすべての色が変わります。

ただし、ダークモードでアプリをバックグラウンドに移動して別のアプリをフォアグラウンドに移動し、アプリに戻ると (バックグラウンドから復元すると)、TabView の色が完全に消えてしまいます。上部の NavigationView は、常に期待どおりに正常に機能します。その後、ライト モードに切り替えると、TabView に正しいライト モードの色が表示されます。ダーク モードに戻すと、正しいダーク モードの TabView の色が復元されます。アプリを再びバックグラウンドに移動し、別のアプリを見て、アプリをフォアグラウンドに戻すと、TabView の色が再び色あせてしまいます。

initと を使用して色呼び出しで無数のことを試しまし.onAppearたが、この動作を修正するものはありませんでした。

何かご意見は?この問題を解決するために時間を割いていただき、ありがとうございます。

明確にするために編集しました。コードはここに追加されます:

import SwiftUI

struct TabbedView: View {
    
    init() {
        UINavigationBar.appearance().titleTextAttributes = [NSMutableAttributedString.Key.foregroundColor:UIColor(named: "mainTextColor") as Any]
        UINavigationBar.appearance().barTintColor = UIColor(named: "barBackground")
        UINavigationBar.appearance().tintColor = UIColor(named: "mainTextColor")
        UITabBar.appearance().isOpaque = true
        UITabBar.appearance().unselectedItemTintColor = UIColor(named: "unselectedTabColor")
        UITabBar.appearance().barTintColor = UIColor(named: "barBackground")
    }
    
    var body: some View {
        
        TabView {
            
            ContentView()
                .tabItem {
                    VStack {
                        Image("Topics69x69")
                        Text("Topics")
                    }
            }.tag(0)
            
            ChangesView()
                .tabItem {
                    VStack {
                        Image("Changes69x69")
                        Text("Changes")
                    }
            }.tag(1)
            
            GospelView()
                .tabItem {
                    VStack {
                        Image("Gospel69x69")
                        Text("Gospel")  
                    }
            }.tag(2)
            
            CopyrightView()
                .tabItem {
                    VStack {
                        Image("Copyright75x75")
                        Text("Copyright")
                    }
            }.tag(3)
            
            AboutView()
                .tabItem {
                    VStack {
                        Image("About75x75")
                        Text("About")
                    }
            }.tag(4)
            
        } // TabView

        // Sets color of the selected tab on the TabBar
        .accentColor(Color("tabImageTintColor"))
        
    } // View
    
} // Main View
4

0 に答える 0