1

I'm looking to create a persistent UIView that doesn't change when different tabs are selected. Since I prefer to use IB, the simplest way seems to be creating a UIView inside a new ViewController and embedding it in the TabBarController. I've tried using the "Embed In Tab Bar Controller", however that creates a new Tab Bar Controller and doesn't seem to provide an option to use my existing one.

Is there any way of accomplishing this? Embed in existing without starting over?

Thanks! enter image description here

moosgrn
  • 379
  • 3
  • 13
  • Already answered, Please find your answer here [link](https://stackoverflow.com/q/7952576/4843725) – Faiz Fareed Mar 30 '19 at 17:12
  • Possible duplicate of [Xcode Tabbed Application - Adding New Tab view](https://stackoverflow.com/questions/7952576/xcode-tabbed-application-adding-new-tab-view) – Faiz Fareed Mar 30 '19 at 17:14
  • Thanks for the link, but I'm not trying to add another tab view ViewController. I'm instead looking to have a UIView (or container, or something else) stay in one spot. – moosgrn Mar 30 '19 at 21:00

1 Answers1

2

You can add a view to your TabBarController in storyboard by drag and drop an UIView on the menu of your TabBarController.

enter image description here

Then you just have to subclass your TabBarController and add this view to the main view of your TabBarController.

import UIKit

class CustomTabBarViewController: UITabBarController {

    @IBOutlet var alwaysOnView: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(alwaysOnView)
    }
}
Wilfried Josset
  • 1,096
  • 8
  • 11