ios - 如何更改 IASKSpecifierValuesViewController 中的背景或文本标签颜色?

标签 ios swift uikit settings inappsettingskit

我在我的项目中使用 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/

相关文章:

ios - 核心位置 iOS 8 兼容 iOS 7

ios - 如何将 Google Analytics 添加到适用于 iOS 设备的 Cocoa Touch Framework

swift - swift 将 UTC 日期转换为本地日期

swift - 如何从此查询访问用户名

ios - 从核心数据模型 Swift 3 中删除一行

objective-c - 能够在后台线程中使用UIKit类

iphone - textField.clearButtonMode =/* 不管怎样 */不起作用

ios - 默认 SDWebImage 缓存大小

ios - 获取 UIScrollView 滚动到顶部

iphone - 为什么这段代码不起作用???如果向右或向左滑动,试图从 UIImageView 更改图像