简体   繁体   中英

Swift: UITabbarController Overlay without covering TabBar in Storyboard

I have a UITabBarController with a custom center UIButton. I created this Button programmatically. I want a overlay(View) to appear whenever (No matter which tab you are on) you press this button. But since I am just starting getting into Swift etc. I would like to design this overlay in the main.storyboard but I can't add a View to the existing UITabBarController ViewController. I already added the addTarget to the Button so that I can call a method to show or hide the overlay.

It would be awesome if you could help me figure this out.

Thanks

You should implement like this way.

class MainTabbarViewController: UITabBarController {

    let viewTabbar : ViewForTabbar!
    override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.        
    viewTabbar = Bundle.main.loadNibNamed("ViewForTabbar", owner: nil, options: nil)?[0] as! ViewForTabbar
    viewTabbar.frame = CGRect(x: 0, y: self.view.bounds.height - 50, width: self.view.bounds.width, height: 50)
    viewTabbar.tag = 100
    viewTabbar.delegate = self

    viewTabbar.initTabbar()
    self.view.addSubview(viewTabbar)
    }
}

This way you can make customized TabbarController

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM