Установить свойство удара и снятия удара для UIButton
let attributesUnstrike = [NSAttributedString.Key.strikethroughStyle : 0]
let titleUnselected = NSAttributedString(string: "YOUR STRING", attributes: attributesUnstrike)
//Set strike for selected state
let attributesStrike = [NSAttributedString.Key.strikethroughStyle : 1]
let titleSelected = NSAttributedString(string: "YOUR STRING", attributes: attributesStrike)
btn.setAttributedTitle(titleUnselected, for: .normal)
btn.setAttributedTitle(titleSelected, for: .selected)
@IBAction func reloadtable(sender:UIButton){
sender.isSelected = !sender.isSelected
//Automatically change Button state automatically based on curent state
}
Обновление:
time805Btn.isSelected = true // To Strike
time805Btn.isSelected = false // To Unstrike
Примечание: Убедитесь, что тип UIButton
должен быть пользовательским.