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

时间:2015-05-31 02:37:07

标签: ios swift

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.

1 个答案:

答案 0 :(得分:2)

假设你有一个标签栏控制器。 你可以在viewDidLoad()

中做这样的事情
self.tabBarController?.tabBar.backgroundColor = UIColor.redColor()
self.tabBarController?.tabBar.tintColor = UIColor.blueColor()

和导航控制器图像

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