|
@@ -14,6 +14,8 @@ class PQCustomSwitchView: UIView {
|
|
|
/// 按钮点击的回调
|
|
|
var switchChangeHandle: ((_ sender: UIButton) -> Void)?
|
|
|
|
|
|
+ var saveBtn:Array<UIButton> = Array.init()
|
|
|
+
|
|
|
override private init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
|
}
|
|
@@ -48,13 +50,17 @@ class PQCustomSwitchView: UIView {
|
|
|
itemBtn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
|
|
|
itemBtn.addCorner(corner:5)
|
|
|
addSubview(itemBtn)
|
|
|
+
|
|
|
+ saveBtn.append(itemBtn)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- /// 按钮点击事件
|
|
|
- /// - Parameter sender: <#sender description#>
|
|
|
- /// - Returns: <#description#>
|
|
|
- @objc func btnClick(sender: UIButton) {
|
|
|
+
|
|
|
+ func selectOneBtn(Index:Int) {
|
|
|
+ BFLog(message: "选择节奏 \(Index)")
|
|
|
+ updateSelectBtn(sender: saveBtn[Index])
|
|
|
+ }
|
|
|
+
|
|
|
+ func updateSelectBtn(sender: UIButton) {
|
|
|
currentItemBtn?.isSelected = false
|
|
|
currentItemBtn?.titleLabel?.font = UIFont.systemFont(ofSize: 13)
|
|
|
currentItemBtn?.backgroundColor = UIColor.hexColor(hexadecimal: "#F9F9F9")
|
|
@@ -62,6 +68,14 @@ class PQCustomSwitchView: UIView {
|
|
|
sender.backgroundColor = UIColor(red: 0.239, green: 0.757, blue: 0.757, alpha: 0.15)
|
|
|
// sender.backgroundColor = .red
|
|
|
currentItemBtn = sender
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 按钮点击事件
|
|
|
+ /// - Parameter sender: <#sender description#>
|
|
|
+ /// - Returns: <#description#>
|
|
|
+ @objc func btnClick(sender: UIButton) {
|
|
|
+
|
|
|
+ updateSelectBtn(sender: sender)
|
|
|
if switchChangeHandle != nil {
|
|
|
switchChangeHandle!(sender)
|
|
|
}
|