example for toggle publishers (UIControl) listening for .valueChanged

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-18 14:10:46 -05:00
parent a9358c9892
commit 231fa9c486

View File

@ -37,7 +37,11 @@ class ToggleViewController: ModelViewController<DefaultToggleModel>, StoryboardI
toggle.leadingAnchor.constraint(equalTo: toggleContainerView.leadingAnchor, constant: 20).isActive = true
toggle.bottomAnchor.constraint(equalTo: toggleContainerView.bottomAnchor, constant: -20).isActive = true
toggle.topAnchor.constraint(equalTo: toggleContainerView.topAnchor, constant: 20).isActive = true
toggle.publisher(for: .valueChanged).sink { toggle in
print("toggle changed: \(toggle.isOn)")
}.store(in: &subscribers)
showTextStack.isHidden = true
view.addGestureRecognizer(UITapGestureRecognizer(target: self.view, action: #selector(UIView.endEditing(_:))))
setupPicker()