我正在使用https://github.com/shamasshahid/SSRadioButtonsController 。当我通过 Storyboard添加单选按钮并设置标题时,它工作正常,但是当我尝试通过代码添加单选按钮的设置标题时,它不起作用。
ViewController 类:UIViewController、SSRadioButtonControllerDelegate {
var radioButtonController:SSRadioButtonsController?
覆盖 func viewDidLoad() { super.viewDidLoad()
var buttonArray = [UIButton]()
let radioButton = SSRadioButton(frame: CGRect(x: 20, y: 20, width: 20, height: 20 ))
radioButton.circleRadius = 8
radioButton.setTitle("male", forState: .Normal)
let radioButton1 = SSRadioButton(frame: CGRect(x: 20, y: 60, width: 20, height: 20 ))
radioButton.circleRadius = 8
radioButton.setTitle("female", forState: .Highlighted)
self.view.addSubview(radioButton)
self.view.addSubview(radioButton1)
buttonArray.append(radioButton)
buttonArray.append(radioButton1)
radioButtonController = SSRadioButtonsController(buttons: buttonArray)
radioButtonController!.delegate = self
radioButtonController!.shouldLetDeSelect = true
// Do any additional setup after loading the view, typically from a nib.
}
func didSelectButton(aButton: UIButton?) {
print(aButton)
}
}
最佳答案
找到解决方案,默认按钮标题为白色,我将其更改为黑色,并且工作正常
radioButton1.setTitleColor(UIColor.blackColor(), forState: .Normal)
关于ios - 无法从代码添加 SSRadioButtonsController 单选按钮标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35341897/