我在xcode中的ios中的单选按钮有问题。我想在两个按钮(按钮上的图像)的帮助下实现这一点。如何让两个按钮像单选按钮一样?有什么帮助吗?
答案 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];