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

Popular posts from this blog

store cgpoint in userdefaults iOS swift

libc++abi: terminating due to uncaught exception of type NSException iOS swift