IconLabel - Tai-Kimura/SwiftJsonUI GitHub Wiki
IconLabel
class: SJUILabelWithIcon inherites: SJUIView
Platform Support
- ✅ UIKit: Full support (All attributes available)
- ✅ SwiftUI: Full support (Maps to Label or HStack/VStack with Image and Text)
Attributes for IconLabel
| attribute name | UIKit | SwiftUI | type in json | details | remarks |
|---|---|---|---|---|---|
| text | ✅ | ✅ | string | NSLocalizedString(text, comment:"") will be set to attributedText | |
| iconPosition | ✅ | ✅ | string | Icon position: Left, Right, Top, Bottom | |
| font | ✅ | ✅ | string | Font name for label | |
| fontSize | ✅ | ✅ | float | Font size for label | |
| fontColor | ✅ | ✅ | string | NSAttributedStringKey.foregroundColor | |
| textShadow | ✅ | ✅ Dynamic | string | Text shadow with color, offset, blur | Dynamic mode only |
| selectedFontColor | ✅ | ✅ Dynamic | string | Font color for selected state | Dynamic mode only |
| icon_on | ✅ | ✅ | string | Image name for selected state | |
| icon_off | ✅ | ✅ | string | Image name for normal state | |
| iconMargin | ✅ | ✅ Dynamic | float | Space between icon and label | Dynamic mode only |
| iconSize | ✅ | ✅ | array | Icon size [width, height] | |
| onclick | ✅ | ✅ | string | Tap gesture selector | |
| selected | ✅ | ✅ | boolean/string | Selected state. Can be boolean or @{variableName} | |
| enabled | ✅ | ✅ | boolean/string | view.isEnabled. Can be boolean or @{variableName} |
Properties for IconLabel
public var label: SJUILabel!
label.
public var iconView: UIImageView!
imageView for displaying icon.
public var iconOn: UIImage!
image for state selected.
public var iconOff: UIImage!
image for state normal.
public var fontColor: UIColor!
fontColor for state normal.
public var selectedFontColor: UIColor!
fontColor for state selected.
public var isSelected: Bool = false
selection state.
Functions for Label
public class func createFromJSON(attr: JSON, target: Any, views: inout [String: UIView]) -> SJUILabelWithIcon
This method will be called when it's created from json file. Override This method when you create classes inherite SJUILabelWithIcon class.