iOS 10,UIToolbar 背景色不变

标签 ios swift uitableview uitoolbar ios10

我有一个自 iOS 8 以来就存在的应用程序。它的工作方式是你有一个 UITableView 并点击单元格以产生一个分数,具体取决于分数,底部的 UItoolbar 使用此方法改变颜色:

func updateToolbarAndLabel(score: Int) {

    if(score <= -1) {
        self.toolbar.backgroundColor = UIColor.greenColor()
    } else if(score <= 0) {
        self.toolbar.backgroundColor = .None
    } else if(score <= 9) {
        self.toolbar.backgroundColor = UIColor.greenColor()
    } else if(score <= 29) {
       self.toolbar.backgroundColor = UIColor.yellowColor()
    } else if(score >= 30) {
        self.toolbar.backgroundColor = UIColor.redColor()
    }
    if (score <= 0) {
        self.scoreshow.text = "0"
    } else {
        self.scoreshow.text = (score as NSNumber).stringValue }
}

然后每次点击 TableView 时都会调用它:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

事情是,自从我构建应用程序以来,它一直有效,但在 iOS 10 上,它不起作用。简单地说颜色不会改变...

任何帮助将不胜感激

最佳答案

我能够解决它,它已更改为:BarTintColor,我自己发现它在苹果文档中找不到任何提及它的东西

像这样使用它:self.toolbar.barTintColor

编辑:现在在 GM 发布文档中有一些提及,请参阅下面的答案

关于iOS 10,UIToolbar 背景色不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39107102/

相关文章:

ios - 更改模态视图 Controller 的大小

ios - 如何将可选项解包到变量中,然后在 while 循环的下一次迭代中使用该变量?

C# .NET 3.5 : Memory Pool, 知道对象何时被释放?

arrays - 无法下标类型 '[UInt32]' 的值

ios - IBOutlet 未连接到 uitableviewcell

ios - 使 UIImageView 可从所有 viewController 访问

ios - 如何在iOS导航栏的titleView中获取圆形imageView

uitableview - NSDateFormatter

swift - 如何在 TableView 的一个原型(prototype)单元格内使用两个标签

ios - Swift(iOS) 一个 View Controller 中的两个 ScrollView