Search code examples
iosswiftuikitsettingsinappsettingskit

how to change background or textLabel color in IASKSpecifierValuesViewController?


i' m using InAppSettingsKit on my project. i customized IASKAppSettingsViewController But i don't customize IASKSpecifierValuesViewController.

my IASKAppSettingsViewController Custom Class;

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
  }
}

how do i call the Custom IASKSpecifierValuesViewController class? Note: i'm using storyboard. I'm open in without storyboard solutions. Thank you guys...


Solution

  • Okey, i found a solution.

    i'm override to didSlectRowAtIndexPath method.

    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)
      }
    }
    

    Detail view source code:

    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
      }
    }