[iOS 按钮选择] 记录按钮点击 selected 的代码

//两个按钮 点击那个 另一个就取消选择
//也可以取消两个按钮的选择状态
//也可以对单独一个按钮 进行选择和取消

//微信支付

  • (IBAction)btnWeChatClick:(id)sender {
    if (_btnZFB.selected == YES) {
    _btnZFB.selected = NO;
    _btnWeChat.selected = YES;
    }else{
    _btnWeChat.selected = !_btnWeChat.selected;
    }

}
//支付宝支付

  • (IBAction)btnZFBClick:(id)sender {

    if (_btnWeChat.selected == YES) {
    _btnWeChat.selected = NO;
    _btnZFB.selected = YES;
    }else{
    _btnZFB.selected = !_btnZFB.selected;
    }

}

你可能感兴趣的:([iOS 按钮选择] 记录按钮点击 selected 的代码)