iOS Question Change segment control text color

webhost.company

Active Member
Licensed User
Longtime User
Hello
I have many question about b4i :)
I need to change text color of segment control and remove border of it
And i need to combine text and image in segment control
OOOO many question
Maybe?
 

tufanv

Expert
Licensed User
Longtime User
I dont think it is possible to add image to segmented control and remove borders. You can implement your own segmented control with 2 panels standing next to each other.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use FontAwesome to add icons to the text:

SS-2017-05-07_08.12.26.png


B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("1")
   NavControl.ShowPage(Page1)
   SetSegmentedControlFont(SegmentedControl1, Font.CreateFontAwesome(16))
   SegmentedControl1.SetItems(Array("Apple " & Chr(0xF179), "Google " & Chr(0xF1A0)))
End Sub

Sub SetSegmentedControlFont(seg As SegmentedControl, fnt As Font)
   Dim no As NativeObject = seg
   Dim dict As NativeObject
   dict = dict.Initialize("B4IAttributedString").RunMethod("createAttributes::", Array(fnt, dict.ColorToUIColor(Colors.Black)))
   no.RunMethod("setTitleTextAttributes:forState:", Array(dict, 0))
End Sub
 
Upvote 0

webhost.company

Active Member
Licensed User
Longtime User
You can use FontAwesome to add icons to the text:

SS-2017-05-07_08.12.26.png


B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("1")
   NavControl.ShowPage(Page1)
   SetSegmentedControlFont(SegmentedControl1, Font.CreateFontAwesome(16))
   SegmentedControl1.SetItems(Array("Apple " & Chr(0xF179), "Google " & Chr(0xF1A0)))
End Sub

Sub SetSegmentedControlFont(seg As SegmentedControl, fnt As Font)
   Dim no As NativeObject = seg
   Dim dict As NativeObject
   dict = dict.Initialize("B4IAttributedString").RunMethod("createAttributes::", Array(fnt, dict.ColorToUIColor(Colors.Black)))
   no.RunMethod("setTitleTextAttributes:forState:", Array(dict, 0))
End Sub
Thanks
 
Upvote 0

webhost.company

Active Member
Licensed User
Longtime User
You can use FontAwesome to add icons to the text:

SS-2017-05-07_08.12.26.png


B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("1")
   NavControl.ShowPage(Page1)
   SetSegmentedControlFont(SegmentedControl1, Font.CreateFontAwesome(16))
   SegmentedControl1.SetItems(Array("Apple " & Chr(0xF179), "Google " & Chr(0xF1A0)))
End Sub

Sub SetSegmentedControlFont(seg As SegmentedControl, fnt As Font)
   Dim no As NativeObject = seg
   Dim dict As NativeObject
   dict = dict.Initialize("B4IAttributedString").RunMethod("createAttributes::", Array(fnt, dict.ColorToUIColor(Colors.Black)))
   no.RunMethod("setTitleTextAttributes:forState:", Array(dict, 0))
End Sub
How can i get hex data for each icon?
 
Upvote 0
Top