-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathDatePatternButton.swift
40 lines (34 loc) · 1.07 KB
/
DatePatternButton.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
//
// DateFieldButton.swift
// OpenGpxTracker
//
// Created by Vincent Neo on 17/4/20.
//
import UIKit
/// Each individual button that represents a date pattern
class DatePatternButton: UIButton {
/// DateFormatter-friendly pattern of that the button holds.
///
/// such as `YYYY` or `s`
var pattern = String()
/// For dealing with button tap highlight
override var isSelected: Bool {
didSet {
if #available(iOS 13.0, *) {
backgroundColor = isSelected ? .highlightKeyboardColor : .keyboardColor
} else {
backgroundColor = isSelected ? .highlightLightKeyboard : .lightKeyboard
}
}
}
/// For dealing with button tap highlight
override var isHighlighted: Bool {
didSet {
if #available(iOS 13.0, *) {
backgroundColor = isHighlighted ? .highlightKeyboardColor : .keyboardColor
} else {
backgroundColor = isHighlighted ? .highlightLightKeyboard : .darkKeyboard
}
}
}
}