Segment - Tai-Kimura/SwiftJsonUI GitHub Wiki
Segment
class: SJUISegmentedControl inherites: UISegmentedControl
Platform Support
- ✅ UIKit: Full support (All attributes available)
- ✅ SwiftUI: Full support (Maps to Picker with segmented style)
Attributes for Segment
| attribute name | UIKit | SwiftUI | type in json | details | remarks |
|---|---|---|---|---|---|
| items | ✅ | ✅ | array/string | String array or string separated by "," for segment items | |
| selectedIndex | ✅ | ✅ | integer/string | Selected segment index. Can be integer or @{variableName} | |
| enabled | ✅ | ✅ | boolean/string | segmentedControl.isEnabled. Can be boolean or @{variableName} | |
| tintColor | ✅ | ✅ | string | segmentedControl.tintColor | |
| normalColor | ✅ | ✅ | string | Default color for text of items | |
| selectedColor | ✅ | ✅ | string | Selected color for text of items | |
| valueChange | ✅ | ✅ | string | Value change event selector (onChange in SwiftUI) | |
| momentary | ✅ | ❌ | boolean | Momentary selection mode | UIKit only |
| apportionsSegmentWidthsByContent | ✅ | ❌ | boolean | Size segments based on content | UIKit only |
Funcitons for Segment
public class func createFromJSON(attr: JSON, target: Any, views: inout [String: UIView]) -> SJUISegmentedControl
This method will be called when it's created from json file. Override This method when you create classes inherite SJUISegmentedControl class.