What's the best way to hide a tab in a TabNavigator?

后端 未结 3 1349
时光取名叫无心
时光取名叫无心 2021-02-15 05:26

I\'d like to conditionally hide a tab in a TabNavigator. It seems that setting visible doesn\'t work properly (presumably because this is how the TabNavigator hides the tabs th

3条回答
  •  梦毁少年i
    2021-02-15 05:57

    You might want to check out the flexlib project. They have a component called SuperTabNavigator that adds a lot of functionality to the base Flex TabNavigator, including hiding tabs (I think).

    If you do have to create your own component, though, it's a bit more tricky. The thing to know is that "tabs" are actually specially styled buttons, contained within a TabBar component (the TabBar is then contained within the TabNavigator). What you'll have to do then, is subclass TabNavigator and have some property on your views (i.e. the canvases, etc. that are added to the TabNavigator) that is bound to the visible and includeInLayout properties of the TabBar buttons.

    In essence, what you'll have is something like:

    BindingUtils.bindProperty( tabButton, "visible", view, "someProperty" );
    BindingUtils.bindProperty( tabButton, "includeInLayout", view, "someProperty" );
    

提交回复
热议问题