我在我的项目中使用 InAppSettingsKit。 我定制了 IASKAppSettingsViewController 但我没有定制 IASKSpecifierValuesViewController。
我的 IASKAppSettingsViewController 自定义类;
import UIKit
class SettingsViewController: IASKAppSettingsViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAt: indexPath)
cell.backgroundColor = .clear
cell.textLabel?.textColor = .white
cell.detailTextLabel?.textColor = .gray
cell.selectionStyle = .none
return cell
}
}
如何调用自定义 IASKSpecifierValuesViewController 类? 注意:我正在使用 Storyboard。我在没有 Storyboard 解决方案的情况下开放。谢谢大家...
最佳答案
好的,我找到了解决方案。
我重写了 didSlectRowAtIndexPath 方法。
import UIKit
class SettingsViewController: IASKAppSettingsViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.backgroundColor = .black
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAt: indexPath)
cell.backgroundColor = .clear
cell.textLabel?.textColor = .white
cell.selectionStyle = .none
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//Creating specifier object
let specifier = self.settingsReader.specifier(for: indexPath)
//Creating a custom IASKSpecifierValuesViewController instance
let targetViewController = SettingsDetail(style: .grouped)
targetViewController.currentSpecifier = specifier
targetViewController.settingsStore = settingsStore
targetViewController.settingsReader = settingsReader
self.navigationController?.pushViewController(targetViewController, animated: true)
}
}
详细查看源码:
import UIKit
class SettingsDetail: IASKSpecifierValuesViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.backgroundColor = .black
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAt: indexPath)
cell.backgroundColor = .clear
cell.textLabel?.textColor = .white
cell.selectionStyle = .none
return cell
}
}
关于ios - 如何更改 IASKSpecifierValuesViewController 中的背景或文本标签颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50274604/