gpt4 book ai didi

ios - 无法从代码添加 SSRadioButtonsController 单选按钮标题

转载 作者:行者123 更新时间:2023-11-30 13:42:59 25 4
gpt4 key购买 nike

我正在使用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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com