-
Notifications
You must be signed in to change notification settings - Fork 0
/
UIPickerView+Extensions.swift
40 lines (34 loc) · 1.07 KB
/
UIPickerView+Extensions.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// UIPickerView+Extensions.swift
// OYExtensions
//
// Created by osmanyildirim
//
import UIKit
extension UIPickerView: OYInit {
public typealias ViewType = UIPickerView
/// Get and Set text color of UIPickerView
public var oy_textColor: UIColor? {
get { value(forKeyPath: "textColor") as? UIColor }
set(value) { setValue(value, forKeyPath: "textColor") }
}
/// Get and Set indicator color of UIPickerView
public var oy_indicatorColor: UIColor? {
get {
guard !subviews.isEmpty else { return nil }
if subviews.count > 1 && subviews[0].subviews.count > 1 {
return subviews[0].subviews[1].backgroundColor
}
return nil
}
set(value) {
guard !subviews.isEmpty else { return }
if subviews[0].subviews.count > 1 {
subviews[0].subviews[1].backgroundColor = value
}
if subviews[0].subviews.count > 2 {
subviews[0].subviews[2].backgroundColor = value
}
}
}
}