skip to Main Content

It is visible if i comment part where i set my ViewControllers.
It is like been superimposed by other ViewControllers. Cause it works but i can’t see it.
When i tap bottom parts of screen color of screen changes to colors which i assign to controllers.

My run

import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?


    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        
        guard let windowScene = (scene as? UIWindowScene) else { return }
        window = UIWindow()
        window?.windowScene = windowScene
        window?.rootViewController = MusicTabBarController()
        window?.makeKeyAndVisible()
    }

}
class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .blue
    }

}

class SearchViewController: UITableViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .orange
    }

}

these are my SceneDelegate and ViewControllers codes, code of my main controller is on the screenshot

2

Answers


  1. Chosen as BEST ANSWER

    this piece of code helped to solve my problem

     let appearance = UITabBarAppearance()
        appearance.configureWithOpaqueBackground()
        appearance.backgroundColor = .white
        tabBar.standardAppearance = appearance
        tabBar.scrollEdgeAppearance = tabBar.standardAppearance
    

  2. Zhiger Sairan

    your TabBar isn’t disappeared. As I can see on view debugger enter image description here
    You have to set image or/and title to your tabbarItem in UIViewControllers.

    It’s small code example, that helps:

    class MusicTabBarController: UITabBarController {
        override func viewDidLoad() {
            super.viewDidLoad()
            
            view.backgroundColor = .gray
            
            let searchVC = SearchViewController()
            searchVC.tabBarItem.title = "SearchViewController"
            let playerVC = ViewController()
            playerVC.tabBarItem.title = "ViewController"
            viewControllers = [
                searchVC,
                playerVC
            ]
        }
    }
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search