SkinViewController.swift 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //
  2. // SkinViewController.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2019/6/13.
  6. // Copyright © 2019 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class SkinViewController: UIViewController {
  10. @IBOutlet weak var redButton: UIButton!
  11. @IBOutlet weak var blueButton: UIButton!
  12. @IBAction func redButtonAction(_ sender: UIButton) {
  13. print("click red theme................")
  14. self.setThemeAndRefreshUI(theme: "red")
  15. }
  16. @IBAction func blueButtonAction(_ sender: UIButton) {
  17. print("click blue theme................")
  18. self.setThemeAndRefreshUI(theme: "blue")
  19. }
  20. override func viewDidLoad() {
  21. super.viewDidLoad()
  22. self.title = "个性换肤"
  23. self.redButton.cornerRadius = 8.0
  24. self.blueButton.cornerRadius = 8.0
  25. self.redButton.setBackgroundColor(UIColor.lightGray, forState: .disabled)
  26. self.blueButton.setBackgroundColor(UIColor.lightGray, forState: .disabled)
  27. if let themeName = O2ThemeManager.currentTheme?["name"] as? String {
  28. print("themeName:\(themeName)")
  29. if themeName == "red" {
  30. self.redButton.isEnabled = false
  31. self.blueButton.isEnabled = true
  32. }else if themeName == "blue" {
  33. self.redButton.isEnabled = true
  34. self.blueButton.isEnabled = false
  35. }
  36. }
  37. }
  38. private func setThemeAndRefreshUI(theme: String) {
  39. AppConfigSettings.shared.themeName = theme
  40. O2ThemeManager.setTheme(plistName: theme, path: .mainBundle)
  41. //搜索框
  42. UISearchBar.appearance().theme_barTintColor = ThemeColorPicker(keyPath: "Base.base_color")
  43. UISearchBar.appearance().tintColor = UIColor.white
  44. UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).theme_tintColor = ThemeColorPicker(keyPath: "Base.base_color")
  45. OOTabBarHelper.initTabBarStyle()
  46. //跳转到主页
  47. let destVC = O2MainController.genernateVC()
  48. // destVC.selectedIndex = 2 // 首页选中 TODO 图标不亮。。。。。
  49. UIApplication.shared.keyWindow?.rootViewController = destVC
  50. UIApplication.shared.keyWindow?.makeKeyAndVisible()
  51. }
  52. /*
  53. // MARK: - Navigation
  54. // In a storyboard-based application, you will often want to do a little preparation before navigation
  55. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  56. // Get the new view controller using segue.destination.
  57. // Pass the selected object to the new view controller.
  58. }
  59. */
  60. }