SegmentedReliefButton: actually show background states
This commit is contained in:
@@ -28,19 +28,19 @@ class ScriptPolicyControl: UIControl
|
||||
segmentContainer.children = [ allowButton, denyButton ]
|
||||
addSubview(segmentContainer)
|
||||
|
||||
allowButton.showsTouchWhenHighlighted = false
|
||||
allowButton.addAction(UIAction(handler: { [unowned self] _ in
|
||||
self.policyStatus = .allowed
|
||||
self.sendActions(for: .valueChanged)
|
||||
}), for: .touchUpInside)
|
||||
allowButton.imageView?.contentMode = .scaleAspectFit
|
||||
addSubview(allowButton)
|
||||
|
||||
denyButton.showsTouchWhenHighlighted = false
|
||||
denyButton.addAction(UIAction(handler: { [unowned self] _ in
|
||||
self.policyStatus = .blocked
|
||||
self.sendActions(for: .valueChanged)
|
||||
}), for: .touchUpInside)
|
||||
denyButton.imageView?.contentMode = .scaleAspectFit
|
||||
addSubview(denyButton)
|
||||
}
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
@@ -54,15 +54,19 @@ class ScriptPolicyControl: UIControl
|
||||
|
||||
if policyStatus == .allowed {
|
||||
allowButton.tintColor = .blue
|
||||
allowButton.remainsPressed = true
|
||||
allowButton.setImage(UIImage(systemName: "play.circle.fill"), for: .normal)
|
||||
|
||||
denyButton.tintColor = .darkGray
|
||||
denyButton.tintColor = nil
|
||||
denyButton.remainsPressed = false
|
||||
denyButton.setImage(UIImage(systemName: "stop.circle"), for: .normal)
|
||||
} else {
|
||||
allowButton.tintColor = .darkGray
|
||||
allowButton.tintColor = nil
|
||||
allowButton.remainsPressed = false
|
||||
allowButton.setImage(UIImage(systemName: "play.circle"), for: .normal)
|
||||
|
||||
denyButton.tintColor = .red
|
||||
denyButton.remainsPressed = true
|
||||
denyButton.setImage(UIImage(systemName: "stop.circle.fill"), for: .normal)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user