创建复选框

时间:2017-04-29 08:40:42

标签: ios objective-c uibutton

以下是我的实施代码: -

 [self.tncCheckBoxLabel setTitle:@"Accept Terms and Conditions" forState:UIControlStateNormal];
    [self.tncCheckBoxLabel setImage:[UIImage imageNamed:@"Unchecked Checkbox Filled-50.png"] forState:UIControlStateNormal];
    [self.tncCheckBoxLabel setImage:[UIImage imageNamed:@"Checked Checkbox Filled-50.png"] forState:UIControlStateSelected];

//onClick method
- (IBAction)tncCheckBoxPressed:(id)sender {
    //self.tncCheckBoxLabel.selected = !self.tncCheckBoxLabel.selected;
    self.tncCheckBoxLabel.selected = !self.tncCheckBoxLabel.selected;
}

初步观点:

enter image description here

点击按钮后的视图:

enter image description here

初始视图很好,但点击按钮后,图像会自动包裹在文本上。

我想在左侧显示看起来像初始视图的选中图像。

0 个答案:

没有答案