0

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

4

1 回答 1

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];
于 2013-01-11T11:48:46.983 回答