我正在使用M13Checkbox吊舱。我想在选中复选框时将“记住我”打印到labeltextfield,而在未选中复选框时将“记住我”打印。当我单击它时,它只是说:“不记得我了。”
let checkboxm13: M13Checkbox = {
let checkboxe = M13Checkbox()
checkboxe.stateChangeAnimation = .stroke
checkboxe.addTarget(self, action: #selector(checkboxvalue(sender:)), for: .valueChanged)
return checkboxe
}()
@objc func checkboxvalue(sender: Checkbox) {
if sender.isSelected == true {
labelcheckbox.text = ("Beni Hatırla")
}
if sender.isSelected == false {
labelcheckbox.text = ("Hatırlama")
}
}
答案 0 :(得分:0)
使用checkState
而不是isSelected
@objc func checkboxvalue(_ sender: M13checkbox) {
switch sender.checkState {
case .checked:
labelcheckbox.text = "Beni Hatırla"
break
case .unchecked:
labelcheckbox.text = "Hatırlama"
break
case .mixed:
//empty...
break
}
}