我有一个自 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/