While CMP provides excellent UI sharing, I need to ensure these specific components maintain their native performance and look-and-feel. I understand that I need to use UIKitView to bridge native iOS views, but I'm struggling with the boilerplate required to wrap a SwiftUI View into something Compose can render in iosMain.
The Goal:
I want to pass a title string from my shared Compose code and have it rendered inside a native SwiftUI VStack.
My Current Setup:
In my commonMain, I have an expect function:
Kotlin
Код: Выделить всё
@Composable
expect fun NativeButton(title: String, onAction: () -> Void)
Как реализовать фактическую часть в iosMain? Specifically:
- How do I use UIHostingController to convert the SwiftUI view into a UIViewController?
- How do I extract the UIView from that controller for use inside the UIKitView factory?
- How do I handle updates if the title state changes in Compose?
Подробнее здесь: https://stackoverflow.com/questions/798 ... -uikitview
Мобильная версия