在Swift 2.0中有谁能告诉我如何在我的UITabBar图标中覆盖Xcode的默认灰色?这个问题没有为我解决:Tab bar item icons appear darker。
答案 0 :(得分:4)
在我的第一个视图控制器的viewDidLoad中,我放置了以下内容,它就像一个魅力:
let aTabArray: [UITabBarItem] = (self.tabBarController?.tabBar.items)!
for item in aTabArray {
item.image = item.image?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
item.imageInsets = UIEdgeInsetsMake(7, 0, -7, 0)
}
答案 1 :(得分:0)
你需要为UITabBarItem设置颜色,否则你必须设置In UITabBarItem以及需要为UITabBarItem设置imageInsets,如UITabBarItem
.fail(function(error) {
console.log(error); //logs "Couldn't save all" or "Couldn't save the challenge"
});
和imageInset:
let customTabBarItem:UITabBarItem = UITabBarItem(title: nil, image: UIImage(named: "favorites.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), selectedImage: UIImage(named: "favorites_h.png")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal))