ThemeStatePicker.swift 671 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // ThemeStatePicker.swift
  3. // SwiftTheme
  4. //
  5. // Created by Gesen on 2017/1/28.
  6. // Copyright © 2017年 Gesen. All rights reserved.
  7. //
  8. import UIKit
  9. final class ThemeStatePicker: ThemePicker {
  10. typealias ValuesType = [UInt: ThemePicker]
  11. var values = ValuesType()
  12. convenience init?(picker: ThemePicker?, withState state: UIControl.State) {
  13. guard let picker = picker else { return nil }
  14. self.init(v: { 0 })
  15. values[state.rawValue] = picker
  16. }
  17. func setPicker(_ picker: ThemePicker?, forState state: UIControl.State) -> Self {
  18. values[state.rawValue] = picker
  19. return self
  20. }
  21. }