Skip to content

miku1958/SwiftUIKit

Repository files navigation

SwiftUIKit

A SwfitUI style UIKit

Requirement

  • Xcode 11

  • Swift5.0

Usage

Text

let label = UILabel()

label.swift.text = Text("text1")
	.background(.black)
label.swift.text += Text("text2")
	.foregroundColor(Color(.red))
	
label.swift.text?.onTapGesture { print("tap") }

label.swift.text +=  Text("text3\(Text: #imageLiteral(resourceName: "icon_sale_member"), width: 17)")
	.foregroundColor(.yellow)
	.tracking(10)

label.swift.text += Text("text4")
		.onLongPressGesture { print("longPress") }

image-20190930104031246

Also support UITextField and UITextView, but tap/longPress gesture may conflict with own gesture

Font

The usage is the same as SwiftUI

Font().italic()

get UIFont

Font().italic().uiFont