TabView vs SegmentedBar

后端 未结 2 2040
名媛妹妹
名媛妹妹 2021-01-26 21:18

I am creating SegmentedBar in native script. I am able to create segments but I am not able to add Label to segment view.



        
2条回答
  •  没有蜡笔的小新
    2021-01-26 21:38

    The Segmented bar is described in a good way by Apple:

    A segmented control is a horizontal control made of multiple segments, each segment functioning as a discrete button.

    So basically: A Segmented Bar is a couple of buttons (visually) connected to each other. Just think of them like buttons with a specific look.

    A TabView on the other hand the tabs (the items you click) and a connected view to each tab.

    What you're doing in your code is that you're trying to combine mechanics of the TabView with the SegmentedBar.

    Take a look at these two code examples.

    First, the SegmentedBar. Here is an example. When you click the "First", "Second" or "Third" button nothing will happen. To react on a button press you've to bind the selectedIndex to an Observable object property and do your logic in the on the propertyChange event.

    
        
            
            
            
        
    
    

    The TabView, on the other hand, consist of two things, the tabs themselves (the things you press) and a View connected to each tab. So when you click a tab the view gets changed.

     
       
         
           
              
         
         
           
              
         
       
     
    

    These two components are used for different things. E.g. for filtering a list (show all mails, show only unread mails...) you usually use the segmented bar as you don't want to change the view - you want to change the content of the view. The TabView is used for when you actually want to display a whole new view.

提交回复
热议问题