iOS Question Navigation bar set

fishwolf

Well-Known Member
Licensed User
Longtime User
Thre questions on top navigation bar:

1) is it possible change color to title text ?

2) is it possible set font properties (bold for example, or dimension) ?

3) If i use a image into navigation bar, a image white with transparent background (android icon),
why the white color is show as blue ?

Thanks
ic_action_action_help.png
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1, 2) Yes. You can use this code to change the title style:
B4X:
Private Sub Application_Start (nav As NavigationController)
   SetNavigationBarTitleStyle(Colors.Red, Font.CreateNewBold(20))
   Dim nav As NavigationController
   nav.Initialize("nav")
   App.KeyController = nav
   NavControl = nav
   Page1.Initialize("Page1")
   NavControl.ShowPage(Page1)
   Page1.RootPanel.LoadLayout("1")
End Sub

Sub SetNavigationBarTitleStyle(Color As Int, Fnt As Font)
   Dim attributes As NativeObject
   attributes = CreateMap("NSFont": Fnt, "NSColor": attributes.ColorToUIColor(Color))
   Dim no As NativeObject
   no.Initialize("UINavigationBar").RunMethod("appearance", Null) _
     .RunMethod("setTitleTextAttributes:", Array(attributes.RunMethod("ToDictionary", Null)))
End Sub
Note that you need to create a new NavigationController and set it as the KeyController (see the code above).

3) The image will show as a single color image based on the non-transparent pixels.
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Thanks,

1-2) OK

point 3) i don't understand if is possibile have white icon ?
now icon and the result are as attachment.
 

Attachments

  • ic_action_content_new_email.png
    ic_action_content_new_email.png
    599 bytes · Views: 387
  • ic_action_content_new_email - IOS.png
    ic_action_content_new_email - IOS.png
    629 bytes · Views: 367
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
thanks, i haven't see the properties

is it change also the color to the back navigation button ?

i have notice that the hide of back into designer doesn't work.

Change the button TintColor property to change its color.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
i have notice that the hide of back into designer doesn't work.
It does work. I just tested it.
Make sure that you set the property to the current page (the top most page).

You can set the navigation bar tintColor property to change the color of all the bar buttons:
B4X:
Sub SetNavigationBarTintColor(clr As Int)
   Dim no As NativeObject = NavControl
   no.GetField("navigationBar").SetField("tintColor", no.ColorToUIColor(clr))
End Sub
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
It does work. I just tested it.
Make sure that you set the property to the current page (the top most page).

You can set the navigation bar tintColor property to change the color of all the bar buttons:
B4X:
Sub SetNavigationBarTintColor(clr As Int)
   Dim no As NativeObject = NavControl
   no.GetField("navigationBar").SetField("tintColor", no.ColorToUIColor(clr))
End Sub

I would change font and size to text of prompt, i'm try to replace

setTitleTextAttributes with setPromptTextAttributes, but doen't work.

other to show me the final solution, can you show me how to find native parameters?

i hope the next version will have these parameters in basic or design mode :)
 
Upvote 0

tcgoh

Active Member
Licensed User
Longtime User
Is its possible to set the toprightbutton text on runtime

page1.TopRightButtons.Add("KKK")
or
page1.TopRightButtons.Add(edittext1.text)
 
Upvote 0
Top