Closed scubax07 closed 4 years ago
This is basically a duplicate of #196. I’ll try to look into it.
Thanks man.
I was able to get a work around this issue by getting the current view controller and adding the action button to its view with necessary constraints.
guard let currentView = HelperMethods.getCurrentViewController()?.view else { return } currentView.addSubview(actionButton)
@scubax07 Hey ! Can you share your code of how you solve this? I'm trying to add the button in the middle of the tabbar and I could, but the actions doesn't work and I think that you have fixed it.
@scubax07 Hey ! Can you share your code of how you solve this? I'm trying to add the button in the middle of the tabbar and I could, but the actions doesn't work and I think that you have fixed it.
Hi, I added the FAB button to the root controller with necessary constraints.
`
let appDelWin = UIApplication.shared.windows.first
guard let currentView = appDelWin?.rootViewController?.view else { return }
currentView.addSubview(actionButton)
actionButton.translatesAutoresizingMaskIntoConstraints = false
actionButton.centerXAnchor.constraint(equalTo: currentView.centerXAnchor).isActive = true
actionButton.bottomAnchor.constraint(equalTo: currentView.bottomAnchor, constant: -50).isActive = true `
I did this in my main tab controller class. Also don't forget to hide/unhide when you switch controllers as per your need. Hope this helps.
self.tabBar.addSubview(middleBtn) middleBtn.addSubview(actionButton) actionButton.translatesAutoresizingMaskIntoConstraints = false actionButton.centerXAnchor.constraint(equalTo: middleBtn.centerXAnchor).isActive = true actionButton.centerYAnchor.constraint(equalTo: middleBtn.centerYAnchor).isActive = true self.view.layoutIfNeeded()