I am trying to update my project to iOS 13. I used to hide the tabbar using a CGAffineTransform translation and it worked like a charm until I updated to Xcode 11 and executed my code on iOS 13.
I have tried recreate a small project with a simple UITabBarController and a simple UIViewController with a button to show/hide my tabbar. (See below).
Even the transformation to identity doesn't works as expected.
Others CGAffineTransform like rotation woks as expected.
@objc fileprivate func showOrHideTabbar() {
if !hidden {
print("hiding")
UIView.animate(withDuration: 0.7, delay: 0, options: .curveEaseOut, animations: {
self.tabBarController?.tabBar.transform = CGAffineTransform(translationX: 0, y: 100)
})
} else {
print("showing")
UIView.animate(withDuration: 0.7, delay: 0, options: .curveEaseOut, animations: {
self.tabBarController?.tabBar.transform = .identity
})
}
hidden = !hidden
}
I know this might be late but it may be helpful for other users looking for this answer. To translate the tab bar to the right/left/top/bottom you would need to change its origin. So, instead of this line:
self.tabBarController?.tabBar.transform = CGAffineTransform(translationX: 0, y: 100)
You should change it to this line:
self.tabBarController?.tabBar.frame.origin.y += 100
Ofcourse, you can change the value 100 to suit your needs, this line will move your tab bar to the bottom, if you want it to move to the top you would need to do this instead:
self.tabBarController?.tabBar.frame.origin.y -= 100
Obviously if you want to change the x position, you would change .y to .x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With