ios – How do I get show the UITabController to point out above the tab bar?


Beneath is my Swift code to show a tab bar controller utilizing UITabController:

class ViewController: UIViewController {

    personal let button: UIButton = {
        let button = UIButton(body: CGRect(x:0, y:0, width: 200, top: 52))
        button.setTitle("Log in", for: .regular)
        button.backgroundColor = .white
        button.setTitleColor(.black, for: .regular)
        return button
    override func viewDidLoad() {
        view.backgroundColor = .systemBlue
        button.addTarget(self, motion: #selector(didTapButton), for: .touchUpInside)
        // Do any extra setup after loading the view.

    override func viewDidLayoutSubviews() {
        button.heart = view.heart

    @objc func didTapButton(){
        let tabBarVC = UITabBarController()
        let vc1 = FirstViewController()
        let vc2 = SecondViewController()
        let vc3 = ThirdViewController()
        let vc4 = FourthViewController()
        let vc5 = FifthViewController()
        vc1.title = "Residence"
        tabBarVC.setViewControllers([vc1], animated: false)
        tabBarVC.modalPresentationStyle = .fullScreen
        current(tabBarVC, animated: true)

class FirstViewController: UIViewController {
    override func  viewDidLoad() {
        view.backgroundColor = .orange
        title = "Residence"

I’ve omitted the code for different controllers to scale back verbosity

I obtained this code from a youtube video from an older model of xcode, beneath are the iamges of my consequence and the one I’m anticipating:

End result:

enter image description here


enter image description here

How do I get the window to finish above the tab bar?


Leave a Reply