First import the module
import xRadioButton
Creating a xRadioButton
let radioButton = xRadioButton(title: "Water", frame: CGRect(x: 100, y: 150, width: 120, height: 40), font: UIFont.boldSystemFont(ofSize: 14), color: UIColor.cyan)
self.view.addSubview(radioButton)
Getting state of the button
radioButton.isSelected
If you want to receive button selection changes, use the delegate
class ..., xRadioButtonDelegate
let radioButton = xRadioButton(title: "Water", frame: CGRect(x: 100, y: 150, width: 120, height: 40), font: UIFont.boldSystemFont(ofSize: 14), color: UIColor.cyan)
radioButton.tag = 1
radioButton.delegate = self
self.view.addSubview(radioButton)
func didSelectButton(sender:xRadioButton) {
print("Button \(sender.tag) is \(sender.isSelected)")
}
- iOS 9.0+
- Xcode 9+
- Swift 4+
xRadioButton is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'xRadioButton'
akinogunc, akinogunc@gmail.com
xRadioButton is available under the MIT license. See the LICENSE file for more info.