Objective c xcode中单选按钮的问题
我对xcode中ios中的单选按钮有问题。我想通过两个按钮(按钮上的图像)来实现这一点。我如何使这两个按钮像单选按钮一样?有什么帮助吗?您错过了addSubview,我是为您这样做的:)Thnx代表您的答案..但我关心的是如何管理更改两个按钮之间的图像基本上是控件…因为当一个按钮处于uicontrol状态时,其他按钮将处于选中模式,反之亦然..Thnx处于Advacnce使用命令:[btn setSelected:NO]在所有其他btn上循环怎么样;?所以基本上我们需要设置一个bool值来确定按下和释放哪个按钮。你想用“两个单选按钮”做什么,你能更具体一点吗?Objective c xcode中单选按钮的问题,objective-c,radio-button,xcode4.5,Objective C,Radio Button,Xcode4.5,我对xcode中ios中的单选按钮有问题。我想通过两个按钮(按钮上的图像)来实现这一点。我如何使这两个按钮像单选按钮一样?有什么帮助吗?您错过了addSubview,我是为您这样做的:)Thnx代表您的答案..但我关心的是如何管理更改两个按钮之间的图像基本上是控件…因为当一个按钮处于uicontrol状态时,其他按钮将处于选中模式,反之亦然..Thnx处于Advacnce使用命令:[btn setSelected:NO]在所有其他btn上循环怎么样;?所以基本上我们需要设置一个bool值来确定按
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];