I am creating SegmentedBar in native script. I am able to create segments but I am not able to add Label to segment view.
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.