Ios 如何在IASKSpecifierValuesViewController中更改背景或文本标签颜色?
我正在我的项目中使用InAppSettingsKit。Ios 如何在IASKSpecifierValuesViewController中更改背景或文本标签颜色?,ios,swift,uikit,settings,inappsettingskit,Ios,Swift,Uikit,Settings,Inappsettingskit,我正在我的项目中使用InAppSettingsKit。 我自定义了IASKAPSettingsViewController,但没有自定义IASKSpecifierValuesViewController 我的IASKAppSettingsViewController自定义类 import UIKit class SettingsViewController: IASKAppSettingsViewController { override func viewDidLoad() {
我自定义了IASKAPSettingsViewController,但没有自定义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类?
注意:我使用的是故事板。我对没有故事板解决方案的情况持开放态度。谢谢大家…老实说,现在没有一个好的解决方案。您可以做的是:使用方法swizzling覆盖tableView:cellforrowatinexpath:method。另一种方法是使用,当选择时,在其中推送IASKSpecifierValuesViewController子类 或者您可以修改IASK以在IASKSettingsDelegate中添加回调。这可能类似于:
- (UITableViewCell*)tableView:(UITableView*)tableView valueCellForSpecifier:(IASKSpecifier*)specifier index:(NSUInteger)index;
要实现这一点,必须将委托传播到IASKSpecifierValuesViewController,如果实现,它将执行回调
或者,作为一种更灵活的解决方案,我们可以允许使用IASKSpecifierValuesViewController的自定义子类,可以通过在settings.plist中指定IASKVIEWController类来覆盖默认的IASKSpecifierValuesViewController
我欢迎这样的请求!我是IASK的维护者。好的,我找到了解决方案 我正在重写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
}
}
你能说清楚一点吗?IASKSpecifierValuesViewController在做什么?你在哪里打开它?IASKSpecifierValuesViewController是IASKAppSettings视图控制器的详细视图。但是不要定制。