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

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift