iOS Question Position of the image in TabBarItem

cruzeiro991

Member
Licensed User
I would like to know how I can adjust the TabBarIcon so that it is centralized vertically, I believe that the space below the image can be of the title, in b4i it talks to pass empty string for the title does not appear.



B4X:
Sub Process_Globals
    Public App As Application
    Private Page1 As Page
    Private tbcx As TabBarController
    Dim nav1 As NavigationController
End Sub

Private Sub Application_Start (nav As NavigationController)
    nav1 = nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    nav1.ShowPage(Page1)

    tbcx.Initialize("tbc")
    App.KeyController = tbcx
    
    Dim p As Page = nav1
    Dim tbb As TabBarItem
    tbb.Initialize("", LoadBitmap(File.DirAssets, "home.png"), Null)
    p.TabBarItem = tbb   
    
    tbcx.Pages = Array(nav1)   
    
End Sub
 

cruzeiro991

Member
Licensed User
Resolved! If someone needs it in the future.

B4X:
Sub Process_Globals
    Public App As Application
    Private Page1 As Page
    Private tbcx As TabBarController
    Dim nav1 As NavigationController
End Sub

Private Sub Application_Start (nav As NavigationController)
    nav1 = nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    nav1.ShowPage(Page1)

    tbcx.Initialize("tbc")
    App.KeyController = tbcx
  
    Dim p As Page = nav1
    Dim tbb As TabBarItem
    tbb.Initialize("", LoadBitmap(File.DirAssets, "home.png"), Null)
    p.TabBarItem = tbb
  
    'add here
    AdjustTabBarItem(p)
  
    tbcx.Pages = Array(nav1)
  
End Sub

Sub AdjustTabBarItem(atbi As Page)
    Dim no As NativeObject = Me
    no.RunMethod("AdjustTabBarItem:", Array(atbi))
End Sub

#if OBJC
- (void)AdjustTabBarItem:(UIViewController*)atbi {
  atbi.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
  atbi.title = nil;
}
#end if
 
Last edited:
Top