iOS Question Setting Navigation Bar Design Properties

Allan Cameron

Member
Licensed User
Longtime User
Hi Erel--please could you provide some example code for changing properties of items in the Navigation Bar, specifically:
-the Page Title (eg colour, size, font)
-colours and positions of buttons set by code
-how to insert an image into a button set by code

More generally, the most effective way for doing these things.

Thanks
 

Allan Cameron

Member
Licensed User
Longtime User
Page8.Initialize("Page8")
Page8.RootPanel.LoadLayout("Page8")
Dim b1, b2, b3, b4, b5, b6 As BarButton
b1.InitializeBitmap(LoadBitmap(File.DirAssets,"brazil_iphone.png"),"1")
b2.InitializeText("French", "2")
b3.InitializeText("Spanish","3")
b4.InitializeText("German", "4")
b5.InitializeText("Portuguese", "5")
b6.InitializeText(">", "6")

Page8.TopLeftButtons = Array(b1, b2, b3, b4, b5, b6)

'Change colour of bar to Turquoise
Dim no As NativeObject = NavControl
no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(Colors.RGB(91,191,183))))

'Change text color of buttons to white
Dim no As NativeObject = NavControl
no.GetField("navigationBar").SetField("tintColor", no.ColorToUIColor(Colors.RGB(255,255,255)))

ScrollView1.Panel.LoadLayout("Page7")
NavControl.NavigationBarVisible = True
ScrollView1.ContentWidth = LayoutValues.Width
NavControl.ShowPage(Page8)
 
Upvote 0

Allan Cameron

Member
Licensed User
Longtime User
It makes no difference. I have never been able to load an image via the designer and see it in a navbar button in the designer or in the compiled program unlike other buttons which work fine. You just see a colored box which you can change the color of but you do not see the image. What I want to do is present a sequence of flags in the bar which when people click on changes the language of the text. I can do it by not using the navbar but I would really prefer to use the navigation bar. I assume that the type of image file does not matter. I have been using .png which I use in normal buttons.
 
Upvote 0

Allan Cameron

Member
Licensed User
Longtime User
I will do but if you create an image button in the navigation bar or the toolbar via the designer do you see the image on your device via Bridge? I just see a blank box.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This project shows the bitmaps!
B4X:
Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    Dim btn As BarButton
    btn.InitializeBitmap(LoadBitmap(File.DirAssets, "btnCH0.png"), "CH")
    Dim btlList1 As List
    btlList1.Initialize
    btlList1.Add(btn)
    Page1.TopLeftButtons = btlList1

    Dim btn As BarButton
    btn.InitializeBitmap(LoadBitmap(File.DirAssets, "btnCH0.png"), "CH")
    Dim btlList2 As List
    btlList2.Initialize
    btlList2.Add(btn)
    Page1.TopRightButtons = btlList2
  
    Dim btn As BarButton
    btn.InitializeBitmap(LoadBitmap(File.DirAssets, "btnCH0.png"), "CH")
    Dim btlList3 As List
    btlList3.Initialize
    btlList3.Add(btn)
    Page1.ToolbarButtons = btlList3
  
    NavControl.ShowPage(Page1)
    NavControl.ToolBarVisible = True
End Sub
On what device do you use it.
Your texts seem to be long.
 

Attachments

  • BitmapButtons.zip
    1.6 KB · Views: 235
Upvote 0
Top