[英]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? 我正在尝试将TabBar的颜色从默认颜色更改为其他颜色吗? 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() 你可以在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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.