Changing Navigation Controller colour swift

前端 未结 1 420
鱼传尺愫
鱼传尺愫 2021-01-05 11:31

I want to change the navigation bar tint controller colour to the colour: R: 73, G: 155, B: 255, A: 0.7

Till now, I have only been able to change it to the colours i

相关标签:
1条回答
  • 2021-01-05 11:35

    If you want to set the background color of the nav bar:

    UINavigationBar.appearance().barTintColor = UIColor.redColor()
    

    Note RGB values are from 0.0 to 1.0 so you have to divide them by 255 or your color will just be white. Next tint:

    UINavigationBar.appearance().tintColor = UIColor(red: 73.0 / 255.0, green: 155.0 / 255.0, blue: 255.0/ 255.0, alpha: 1.0)
    

    Then to set your title text:

    UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: someColor, NSFontAttributeName: someFont]
    

    Finally for bar button items:

    UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: color, NSFontAttributeName: buttonFont], forState: UIControlState.Normal)
    
    0 讨论(0)
提交回复
热议问题