Sahil Beri Sahil Beri - 1 year ago 99
Swift Question

unable to add SSRadioButtonsController radio button title from code

i'm using . when i add radio buttons through storyboard and set titles it works fine but when i try to add set title of radio button through code it doesn't work.

class ViewController: UIViewController, SSRadioButtonControllerDelegate {

var radioButtonController: SSRadioButtonsController?

override func 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)



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?) {


Answer Source

Found the solution by default button title was white i changed it with black and it is working fine

radioButton1.setTitleColor(UIColor.blackColor(), forState: .Normal)