iOS Code Snippet SegmentedControl accepts only text, no images

The native SegmentedControl acepts text and images.
In B4i it accepts only text.
Is this a simplification, an omission or a technical difficulty ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   NavControl.ShowPage(Page1)
   Page1.RootPanel.LoadLayout("1")
   SetImageSegments(SegmentedControl1, Array(LoadBitmap(File.DirAssets, "smiley.png"), _
     LoadBitmap(File.DirAssets, "icon-40.png")))
End Sub

Sub SetImageSegments(sc As SegmentedControl, Images As List)
   Dim no As NativeObject = sc
   no.RunMethod("removeAllSegments", Null)
   For i = 0 To Images.Size - 1
     no.RunMethod("insertSegmentWithImage:atIndex:animated:", Array(Images.Get(i), i, True))   
   Next
End Sub

Note that only the alpha level of the bitmaps is used.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…