parker88
parker88

Reputation: 327

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.

Upvotes: 1

Views: 1181

Answers (1)

miracle-doh
miracle-doh

Reputation: 596

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)

Upvotes: 2

Related Questions