.xib file at a higher level, to always keep it visible

68 Views Asked by At

in the first ViewController I load TabbarView.xib (yellow rectangle), when I go to the second ViewController it goes away, how can I keep it always visible in any screen I go to?

I would like it on a higher level, to always keep it visible.

first ViewController

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var gotoVC: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        gotoVC.addTarget(self, action: #selector(gotoVCAction), for: .touchUpInside)
        
    }
    
    @objc func gotoVCAction() {
        
        performSegue(withIdentifier: "gotoVC2", sender: nil)
        
    }


}

TabbarView.xib

import UIKit

class TabbarView: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        print("TabbarView")
        
    }
    
}

I would like it on a higher level, to always keep it visible.

enter image description here

enter image description here

enter image description here

Update, after days of research I thought I had found the solution with windowNew?.windowLevel = .alert

but now the gotoVC2 button no longer works, because windowNew covers the entire screen, making the button underneath it no longer usable.

How can I keep usable the buttons at a lower level than WindowNew?

Scene Delegate

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?

var windowNew: UIWindow?

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

There are 0 best solutions below