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

How to blink a button iOS swift?

Convert NsNumber, NSDate to String in iOS Swift

Parse the value from string value iOS swift