Skip to content

Commit

Permalink
fixed layout issues for CBTabBarController not contained in UINavigat…
Browse files Browse the repository at this point in the history
…ionController
  • Loading branch information
askopin committed Mar 30, 2019
1 parent aa9f64f commit 92d0dc8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions CBTabBarController/Classes/CBTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ open class CBTabBarController: UITabBarController {
}
set {
(tabBar as? CBTabBar)?.barHeight = newValue
self.setValue(tabBar, forKey: "tabBar")
}
}

Expand All @@ -90,4 +91,22 @@ open class CBTabBarController: UITabBarController {
delegate?.tabBarController?(self, didSelect: controller)
}
}

private func updateTabBarFrame() {
var tabFrame = tabBar.frame
if #available(iOS 11.0, *) {
tabFrame.size.height = barHeight + view.safeAreaInsets.bottom
} else {
tabFrame.size.height = barHeight
}
tabFrame.origin.y = self.view.frame.size.height - tabFrame.size.height
tabBar.frame = tabFrame
tabBar.setNeedsLayout()
}

@available(iOS 11.0, *)
open override func viewSafeAreaInsetsDidChange() {
super.viewSafeAreaInsetsDidChange()
updateTabBarFrame()
}
}

0 comments on commit 92d0dc8

Please sign in to comment.