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

标签 ios swift

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

相关文章:

ios苹果推送通知服务器端设计

ios - Atos 无法从存档应用程序的 dSYM 中获取符号

IOS FacebookShare 返回错误 'reserved'

ios - 对 UIImage 的 init(data :scale:) method in Swift 3. 0

ios - 我可以将一个 iOS 应用拆分为两个或多个项目吗?

ios - Crashlytics pod 仍在使用 UIWebView 生成 ITMS-90809 : Deprecated API Usage

ios - 如何在 SceneKit 中制作平面镜

ios - 核心数据在swift ios中再次运行应用程序后显示故障记录?

swift - 如何在 Swift 3 中访问传递的 Enum 参数

arrays - 数组的大小在 Swift 中总是返回 0