如何设置navbar和tabbar不透明且边框可见

How to set navbar and tabbar not transparent and their borders visible

我在互联网上找不到关于这个问题的任何信息。我在 UIViewcontroller 中有 tableview,它嵌入在导航控制器中。我希望我的导航栏始终处于滚动状态(边框可见)并且与标签栏一样。这是我拥有的(第一张)和我想要的(第二张)的照片。

在 AppDelegate 文件的 didFinishLaunchingWithOptions 方法中添加:

        //MARK: - NavBar appearance
        let navBarAppearance = UINavigationBarAppearance()
        navBarAppearance.backgroundColor = UIColor(named: "AccentColor")
        UINavigationBar.appearance().standardAppearance  = navBarAppearance
        UINavigationBar.appearance().scrollEdgeAppearance = navBarAppearance
        
        //MARK: - TabBar appearance
        let tabBarAppearance = UITabBarAppearance()
        tabBarAppearance.backgroundColor = UIColor(named: "AccentColor")
        UITabBar.appearance().standardAppearance  = tabBarAppearance
        UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance