https://github.com/ipedro/uikitview
A Wrapper for using UIKit views in SwiftUI
https://github.com/ipedro/uikitview
swiftui swiftui-uikit swiftui-uikit-wrapper uikit wrapper
Last synced: 25 days ago
JSON representation
A Wrapper for using UIKit views in SwiftUI
- Host: GitHub
- URL: https://github.com/ipedro/uikitview
- Owner: ipedro
- License: mit
- Created: 2022-12-16T16:40:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-23T17:56:14.000Z (over 3 years ago)
- Last Synced: 2025-07-24T02:39:45.447Z (11 months ago)
- Topics: swiftui, swiftui-uikit, swiftui-uikit-wrapper, uikit, wrapper
- Language: Swift
- Homepage: https://ipedro.github.io/UIKitView/documentation/uikitview/
- Size: 1.22 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UIKitView
## Documentation
https://ipedro.github.io/UIKitView/documentation/uikitview/
Sample usage:

```swift
var body: some View {
ScrollView {
VStack(spacing: 36) {
UIKitView {
UILabel()
} then: {
$0.adjustsFontForContentSizeCategory = true
$0.numberOfLines = 0
$0.attributedText = NSAttributedString(
string: "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer",
attributes: [
.underlineStyle: NSNumber(value: 1),
.font: UIFont.preferredFont(forTextStyle: .headline),
.foregroundColor: UIColor.systemBackground,
.backgroundColor: UIColor.systemGreen.withAlphaComponent(0.25)
]
)
}
.padding()
.background(Color.accentColor)
.cornerRadius(24)
UIKitView(traits: .fixedSize()) {
UISwitch()
} then: {
$0.backgroundColor = .systemRed.withAlphaComponent(0.1)
}
UIKitView {
UISwitch()
} then: {
$0.backgroundColor = .systemRed.withAlphaComponent(0.1)
}
HStack(spacing: 24) {
// Body Text
Text("Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type.")
// Should look and behave exactly the same
UIKitView {
UILabel()
} then: {
$0.font = .preferredFont(forTextStyle: .body)
$0.adjustsFontForContentSizeCategory = true
$0.numberOfLines = 0
$0.text = "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type."
}
}
HStack(spacing: 24) {
UIKitView(traits: .flexible(layoutPriority: .fittingSizeLevel)) {
UIImageView(image: .init(systemName: "checkmark"))
} then: {
$0.contentMode = .scaleAspectFill
}
.padding()
.background(Color.primary.opacity(0.1))
.aspectRatio(contentMode: .fill)
UIKitView {
UILabel()
} then: {
$0.adjustsFontForContentSizeCategory = true
$0.numberOfLines = 0
$0.text = "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type."
}
}
}
.padding()
}
}
```