I've got a view controller being pushed onto a navigation controller which is inside a tab bar controller. The view controller hidesBottomBarWhenPushed and on view will appear it shows a toolbar. No matter what I try, it won't stop animating the toolbar sliding up / down when the view controller is pushed or popped. This only seems to be an issue on the iPhone X. Does anyone know how work around it?
Asked
Active
Viewed 572 times
0
-
This same problem: https://stackoverflow.com/questions/46232929/why-page-push-animation-tabbar-moving-up-in-the-iphone-x – Alexander Nov 29 '17 at 06:34
1 Answers
0
This answer https://stackoverflow.com/a/47225653/1211917 helps me:
class SafeAreaFixTabBar: UITabBar {
var oldSafeAreaInsets = UIEdgeInsets.zero
@available(iOS 11.0, *)
override func safeAreaInsetsDidChange() {
super.safeAreaInsetsDidChange()
if oldSafeAreaInsets != safeAreaInsets {
oldSafeAreaInsets = safeAreaInsets
invalidateIntrinsicContentSize()
superview?.setNeedsLayout()
superview?.layoutSubviews()
}
}
override func sizeThatFits(_ size: CGSize) -> CGSize {
var size = super.sizeThatFits(size)
if #available(iOS 11.0, *) {
let bottomInset = safeAreaInsets.bottom
if bottomInset > 0 && size.height < 50 && (size.height + bottomInset < 90) {
size.height += bottomInset
}
}
return size
}
override var frame: CGRect {
get {
return super.frame
}
set {
var tmp = newValue
if let superview = superview, tmp.maxY !=
superview.frame.height {
tmp.origin.y = superview.frame.height - tmp.height
}
super.frame = tmp
}
}
}

Alexander
- 157
- 2
- 6