Search code examples
colorslineswiftuitabbar

SwiftUI Add top line to TabBar


How can I add a line/divider on the top of my TabBar for adding some kind of a splitter between my view and TabBar?


Solution

  • I forgot that I have added this code for making the TabBar completely white. But my shadow color was white, so I just changed it to Gray

    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
    }
    

    }