Skip to content

Instantly share code, notes, and snippets.

@Exey
Created March 26, 2020 18:00
Show Gist options
  • Save Exey/681cac404d4617cb8b06af67f95c5860 to your computer and use it in GitHub Desktop.
Save Exey/681cac404d4617cb8b06af67f95c5860 to your computer and use it in GitHub Desktop.
extension UITabBar {
/// // TabBar Hide Mechanism
/// @Published var hideTabBar = false
/// var tabBarSubscriberCancellable: AnyCancellable?
open override func setNeedsDisplay() {
super.setNeedsDisplay()
// tricky subscribe
let coreApp: CoreAppService = ServiceLocator.shared.inject()
if coreApp.tabBarSubscriberCancellable == nil {
coreApp.tabBarSubscriberCancellable = coreApp.$hideTabBar.sink(receiveValue: { hide in
self.alpha = hide ? 0 : 1.0
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment