xcode中单选按钮的问题

时间:2013-01-11 11:42:36

标签: objective-c radio-button xcode4.5

我在xcode中的ios中的单选按钮有问题。我想在两个按钮(按钮上的图像)的帮助下实现这一点。如何让两个按钮像单选按钮一样?有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

UIButton *radioBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[radioBtn setImage:[UIImage imageNamed:@"radioOff.png"] forState:UIControlStateNormal];
[radioBtn setImage:[UIImage imageNamed:@"radioOn.png"] forState:UIControlStateSelected];
[radioBtn setBackgroundColor:[UIColor clearColor]];
[radioBtn addTarget:self action:@selector(myfunc) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:radioBtn];