选中时的Tabman图像色调颜色

时间:2019-08-03 11:46:39

标签: ios iphone uitabbarcontroller swift4

我正在使用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)
    }

使用https://github.com/uias/Tabman

1 个答案:

答案 0 :(得分:1)

选择图像时必须设置图像渲染模式alwaysTemplate,即在barItem forBar atIdex方法中

let image = UIImage(named:
        "myImage")!.withRenderingMode(.alwaysTemplate)
let item = TMBarItem(image:image , badgeValue: "2")