RadioButton迅速

时间:2016-11-15 05:19:46

标签: ios swift

我是swift的新手,现在只在Xcode中嵌入SSRadioButtonsController 我希望在UIAlertView中显示一些文字。

我已经做到了,但根本不起作用。

   @IBAction func infoClicked(sender: UIButton) {
    self.displayAlert("My Health Action Plan Detail", message: "A Health Action Plan is personal plan describing what you need to do to stay healthy. Using the plan can help you focus your health activities.")

    var radioButtonController = SSRadioButtonsController()
    radioButtonController.setButtonsArray([button1!,button2!,button3!])
    var currentButton = radioButtonController.selectedButton()
}

我需要在警报视图中显示一些带文字的单选按钮

1 个答案:

答案 0 :(得分:1)

正如@matt所说,你不能添加UIAlertView或UIAlertController接口。你可以添加ssradion按钮来查看。

        let radioButton = SSRadioButton(frame: CGRect(x: 0, y: 0, width: 100, height: 20 ))
        radioButton.circleRadius = 8
        radioButton.circleColor = UIColor.redColor()
       radioButton.setTitle("1", forState: .Normal)
        radioButton.setTitleColor(UIColor.blackColor(), forState: .Normal)

        let radioButton1 = SSRadioButton(frame: CGRect(x: 0, y: 0, width: 100, height: 20 ))
        radioButton1.circleRadius = 8
        radioButton1.circleColor = UIColor.redColor()
        radioButton1.setTitle("2", forState: .Normal)
        radioButton1.setTitleColor(UIColor.blackColor(), forState: .Normal)

 var radioButtonController = SSRadioButtonsController(buttons: radioButton, radioButton1)
 radioBtnController.delegate = self

添加radiobutton以查看

self.view.addSubView(radioButton)
self.view.addSubView(radioButton1)

如果您想要检测点击了哪个按钮,则需要实施SSRadioButtonControllerDelegate方法didSelectButton