-
-
Notifications
You must be signed in to change notification settings - Fork 488
/
Copy pathBKDropDownCell.swift
48 lines (39 loc) · 1.31 KB
/
BKDropDownCell.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
41
42
43
44
45
46
47
48
//
// BKDropDownCellTableViewCell.swift
// Bark
//
// Created by huangfeng on 2023/2/9.
// Copyright © 2023 Fin. All rights reserved.
//
import DropDown
import UIKit
class BKDropDownCell: DropDownCell {
@IBOutlet var selectBackgroundView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
self.backgroundColor = BKColor.white
self.selectBackgroundView.layer.cornerRadius = 10
self.selectBackgroundView.clipsToBounds = true
}
override func setSelected(_ selected: Bool, animated: Bool) {
let executeSelection: () -> Void = { [weak self] in
guard let `self` = self else { return }
let selectedBackgroundColor = BKColor.grey.lighten5
if selected {
self.selectBackgroundView.backgroundColor = selectedBackgroundColor
self.optionLabel.textColor = BKColor.grey.darken4
} else {
self.selectBackgroundView.backgroundColor = .clear
self.optionLabel.textColor = BKColor.grey.darken3
}
}
if animated {
UIView.animate(withDuration: 0.3, animations: {
executeSelection()
})
} else {
executeSelection()
}
accessibilityTraits = selected ? .selected : .none
}
}