CheckBox implementation in iOS swift
Solution:
func setCheckBox(btn:UIButton) {
btn.setImage(UIImage(named: "uncheckBoxImage"), for: .normal)
btn.setImage(UIImage(named: "checkBoxImage"), for: .selected)
}
call the above function as like below
setCheckBox(btn: CheckBoxBtn)
While click on the checkbox button as like below
CheckBoxBtn.rx.tap.asDriver()
.drive(onNext: { [weak self] in
CheckBoxBtn.isSelected = !(CheckBoxBtn.isSelected ?? false)
}).disposed(by: self.disposebag)
It will be working good for checkbox selection it will change the image.
Comments
Post a Comment