简体   繁体   中英

How to change the color of a TabBar in Swift? Image as Background in Navigation bar?

I'm trying to change the color of my TabBar from the default color to a different color? How do I do this programmatically with swift? Also, how do I assign an image as the background for a navigation bar? Sorry if this is an easy question, I'm new to programming.

let's say if you have a tab bar controller. you can do something like this in viewDidLoad()

self.tabBarController?.tabBar.backgroundColor = UIColor.redColor()
self.tabBarController?.tabBar.tintColor = UIColor.blueColor()

and for navigation controller image

  var image = UIImage(named: "filename")
  self.navigationController?.navigationBar.setBackgroundImage(image, forBarMetrics: UIBarMetrics.Default)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM