HJVisualComponents is a visual component framework. Components:
- Radio button
Add dependency:
.package(url: "https://github.com/ObjectiveC-Challenge/HJVisualComponents.git", from: "1.0.9")
or
- In your project click: File -> Swift Packages -> Add Package Dependency...
- Then, paste https://github.com/ObjectiveC-Challenge/HJVisualComponents
- Then next -> next
- Import HJVisualComponents
import HJVisualComponents
- Create a Radio Button
let radioButtonDefault = RadioButton() // Default init
let radioButtonCustom = RadioButton(multiplier: 0.5, selectedColor: .black, unselectedColor: .gray, fontColor: .black, orientation: .horizontal)) // Custom init
- Setup options
radioButtonDefault.setOptions(["A", "B", "C"])
- Setup radio buttons dimensions
NSLayoutConstraint.activate([
radioButton.widthAnchor.constraint(equalToConstant: 300),
radioButton.heightAnchor.constraint(equalToConstant: 100)
])
You can see better an example of use with Swift here: https://github.com/ObjectiveC-Challenge/SampleSwift
Custom init allows you to set the following parameters:
- multiplier: Button size relative to parent view
- selectedColor: Button color when selected
- unselectedColor: Button color when not selected
- fontColor: Color of the label below the button
- orientation: that represents the button's orientation. Can ben horizontal or vertical.
RadioButton(multiplier: 0.5, selectedColor: .blue, unselectedColor: .red, fontColor: .gray, orientation: .horizontal))
Default init have default values to:
- multiplier: 0.5
- selectedColor: UIColor.black
- unselectedColor: UIColor.gray
- fontColor: UIColor.black
- orientation: .horizontal
RadioButton()
Use this function to configure the quantity and values of radio button's options. The options must be a type that can be converted to NSString.
radioButton.setOptions(["A", "B", "C"])
Use this function to return the selected option. If there aren't select options, this function returns nil.
radioButton.getSelectedValue()