I want to make the state of toggle switch to ON always, even if user tries to make it OFF, it should not change. I tried to use .isUserInterstionEnabled = .false, but that didn’t work. Can somebody help me on this? Thank you in advance
I want to make the state of toggle switch to ON always, even if user tries to make it OFF, it should not change. I tried to use .isUserInterstionEnabled = .false, but that didn’t work. Can somebody help me on this? Thank you in advance
3
Answers
Try using
toggle.isEnabled = false
There are two ways that I see you can achieve what you want.
.disabled()
(the user will see it slightly faded):.onChange(of:)
:1.Make the switch outlet in the view controller.
2.Create
IBAction
of switch and set-:User will try to disable it but it will remain enable.