I developed app where I open firstly UIViewController with login system, here in viewDidLoad I chech if user loggined in (with firebase) like that
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .systemBackground
if Auth.auth().currentUser == nil{
let tap = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard))
view.addGestureRecognizer(tap)
view.addSubview(logoImageView)
logoImageView.center = CGPoint(x: horizontalCenter, y: verticalCenter/2.5)
view.addSubview(emailTextField)
emailTextField.center = CGPoint(x: horizontalCenter, y: verticalCenter)
view.addSubview(passwordTextField)
passwordTextField.center = CGPoint(x: horizontalCenter, y: verticalCenter+50)
view.addSubview(loginButton)
loginButton.center = CGPoint(x: horizontalCenter, y: verticalCenter+100)
view.addSubview(dontHaveAccountButton)
dontHaveAccountButton.center = CGPoint(x: horizontalCenter, y: verticalCenter*1.8)
view.addSubview(showPasswordButton)
showPasswordButton.center = CGPoint(x: horizontalCenter+100, y: verticalCenter+50)
}
else {
view.addSubview(LlogindButton)
LlogindButton.center = CGPoint(x: horizontalCenter, y: verticalCenter+100)
}
}
My config funk looks like:
@objc func config(){
let tabBarVC = UITabBarController()
let vc1 = UINavigationController(rootViewController: feedViewController())
let vc2 = LibraryViewController()
let vc3 = UINavigationController(rootViewController: CreatorViewController())
let vc4 = ProfileViewController()
let vc5 = UINavigationController(rootViewController: SettingsViewController())
vc1.title = "Feed"
vc2.title = "Library"
vc3.title = "Creator Studio"
vc4.title = "Profile"
vc5.title = "Settings"
tabBarVC.setViewControllers([vc1, vc2, vc3, vc4, vc5], animated: false)
guard let items = tabBarVC.tabBar.items else{
return
}
let images = ["house", "book.fill", "paintpalette.fill", "person.circle", "gear"]
for x in 0..<items.count{
items[x].image = UIImage(systemName: images[x])
}
tabBarVC.modalPresentationStyle = .fullScreen
present(tabBarVC, animated: true)
}
So, here is my problem. In config function I am showing UITabBarController()
and if user logged in I want to show one of my bars from UITabBarController
instead of button that call my config func. The same logic provided in instagram and I need something like that.