我正在使用Pod Tabman
以方便使用标签栏控制器
但是选择按钮时我无法更改图像颜色。
我已经尝试了一些方法来像着色图像那样渲染图像视图,但是到目前为止,什么都没有改变。
func setUpTabBar(){
let tabBar = TMBar.TabBar()
tabBar.layout.transitionStyle = .snap
tabBar.fadesContentEdges = true
tabBar.spacing = 16.0
tabBar.buttons.customize { (button) in
button.selectedTintColor = .purple
button.tintColor = .orange
button.font = UIFont.boldSystemFont(ofSize: 14)
}
addBar(tabBar.systemBar(),dataSource: self,at: .bottom)
}
答案 0 :(得分:1)
选择图像时必须设置图像渲染模式alwaysTemplate,即在barItem forBar atIdex方法中
let image = UIImage(named:
"myImage")!.withRenderingMode(.alwaysTemplate)
let item = TMBarItem(image:image , badgeValue: "2")