IconLabel ja - Tai-Kimura/SwiftJsonUI GitHub Wiki

🇺🇸 English | 🇯🇵 日本語

IconLabel

クラス: SJUILabelWithIcon 継承元: SJUIView

プラットフォームサポート

  • UIKit: 完全サポート(すべての属性が利用可能)
  • SwiftUI: 完全サポート(LabelまたはImageとTextのHStack/VStackにマップ)

Labelの属性

属性名 UIKit SwiftUI Compose XML jsonでの型 詳細 備考
iconPosition - string アイコンとテキストの配置。利用可能なリストは以下の通りLeft: IconPosition.leftRight: IconPosition.rightTop: IconPosition.topBottom: IconPosition.bottom
font - string ラベルのフォント名。
fontSize - float ラベルのフォントサイズ。
fontColor - string NSAttributedStringKey.foregroundColor。
textShadow - string NSAttributedStringKey.shadow。利用可能なキーは以下の通り color: shadowColor: 16進文字列offset: shadowOffset.x(最初のオブジェクト)とshadowOffset.y(2番目のオブジェクト): float配列 blur: shadowBlurRadius: float
text - string NSLocalizedString(text, comment:"")がattributedTextに設定されます。
selectedFontColor - string 選択状態のフォント色。
icon_on - string 選択状態の画像名。
icon_off - string 通常状態の画像名。
iconMargin - float アイコンとラベルの間のスペース。
onclick - string この属性でonclickイベントを定義できます。この属性で作成されたセレクターはUITapGestureRecognizerに設定され、UITapGestureRecognizerがラベルに追加されます。

Labelのプロパティ

public var label: SJUILabel!

ラベル。

public var iconView: UIImageView!

アイコンを表示するためのimageView。

public var iconOn: UIImage!

選択状態の画像。

public var iconOff: UIImage!

通常状態の画像。

public var fontColor: UIColor!

通常状態のフォント色。

public var selectedFontColor: UIColor!

選択状態のフォント色。

 public var isSelected: Bool = false

選択状態。

Labelの関数

public class func createFromJSON(attr: JSON, target: Any, views: inout [String: UIView]) -> SJUILabelWithIcon

このメソッドはJSONファイルから作成される際に呼び出されます。 SJUILabelWithIconクラスを継承するクラスを作成する際はこのメソッドをオーバーライドしてください。