iOS Question Change NavBar Text Color

Discussion in 'iOS Questions' started by jcesar, Feb 5, 2015.

  1. jcesar

    jcesar Active Member Licensed User

    Hi

    How can i change the navbar text color ?

    This code change the background color:

    Code:
    Dim no As NativeObject = NavControl
        no.GetField(
    "navigationBar").RunMethod("setBarTintColor:"Array(no.ColorToUIColor(Colors.RGB(0,128,128))))
    If I change to SetTintColor, I can change the button font color.

    But I haven´t found a method to change the Title color.
     
  2. Turbo3

    Turbo3 Active Member Licensed User

    Looks like you would need to use "setTitleTextAttributes:" but you need to provide more than just the color so the Array of data is more complicated.
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Here:
    Code:
    Private Sub Application_Start (Nav As NavigationController)
       NavControl = Nav
       Page1.Initialize(
    "Page1")
       Page1.RootPanel.LoadLayout(
    "1")
       NavControl.ShowPage(Page1)
       Page1.Title = 
    "Title"
       SetTitleColor(Nav, 
    Colors.Red)
    End Sub

    Sub SetTitleColor(nav As NavigationController, clr As Int)
       
    Dim attributes As NativeObject
       
    attributes = attributes.Initialize("B4IAttributedString").RunMethod("createAttributes::", _
         
    Array(Font.CreateNew(18), attributes.ColorToUIColor(clr)))
       
    Dim no As NativeObject = nav
       no.GetField(
    "navigationBar").RunMethod("setTitleTextAttributes:"Array(attributes))
    End Sub
     
  4. Ramezanpour

    Ramezanpour Active Member Licensed User

    how to use this for code module with multiple pages ? (with Tabcontroller)
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    This code will not work with TabBarController. Only with NavigationController.
     
    Ramezanpour likes this.
  6. Rory Mapstone

    Rory Mapstone Member Licensed User

    Does that mean that there is no way to change the text color of a TabBarItem in a TabControlloer
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    It is possible to change the text color of all tab items (to the same color). Start a new thread for this if you like.
     
  8. Rory Mapstone

    Rory Mapstone Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice