Hello everyone!
I'm glad to introduce you to a short Swift library that I've been working on: UIKitViews. This library offers a convenient SwiftUI wrapper around UIView and UIViewController, which facilitates seamless integration of UIKit components within SwiftUI.
Here's what you can do with UIKitViews:
- Easily build and configure UIKit views and controllers right inside SwiftUI using a familiar SwiftUI syntax
- Make a UIKit view self-sizing in the SwiftUI environment
- Adjust the content resizing behaviour of UIKit views
- Environment variables by UIView/UIViewController keypathes
UIKitView {
UILabel().chain
.numberOfLines(0)
.font(.system(34)) // Constant properties
}
.text(title) // Updatable properties
.uiKitViewFixedSize(.vertical)
.uiKitViewContentMode(.fill)
.uiKitViewEnvironment(\UILabel.textColor, .black)
Note: .text
, .numberOfLines
and .font
are not hardcoded methods, it's a property chaining, so any properties of your UIKit views can be used as modifier methods with UIKitView
.