SwiftUI 将顶行添加到 TabBar

SwiftUI Add top line to TabBar

如何在我的 TabBar 顶部添加一个 line/divider 以在我的视图和 TabBar 之间添加某种分隔符?

您可以更改 TabBar 行的颜色

init(){
  UITabBar.appearance().separatorColor = .red
  UITabBar.appearance().separatorInset = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 0)
}

我忘了我已经添加了这段代码来使 TabBar 完全变白。 但是我的阴影颜色是白色的,所以我就把它改成了灰色

extension UITabBarController {
override open func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    let appearance = UITabBarAppearance()
    appearance.configureWithOpaqueBackground()

    appearance.backgroundColor = .white
    appearance.shadowImage = UIImage()
    appearance.shadowColor = .gray

    appearance.stackedLayoutAppearance.normal.iconColor = .black
    appearance.stackedLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]

    self.tabBar.standardAppearance = appearance
}

}