Hey guys, I am trying to use a SwiftView on top of...
# compose-ios
s
Hey guys, I am trying to use a SwiftView on top of my Composable Screen, a SwiftUI Text() using
UIKitViewController
. However, it always seems to add a White background to it. I understand there’s a active issue for it but is there a workaround for it?
Copy code
val factory = LocalNativeViewFactory.current
UIKitViewController(
    modifier = modifier
        .width(100.dp)
        .height(50.dp),

    factory = {
        factory.createTextView(
            label = "IOS Text",
        )
    }
)

struct SimpleIOSText: View {
  var label: String
   
  var body: some View {
  
      Text(label)
        .font(.headline)
     
  }
}
this is a simpler example of what i want to do. My usecase is using .stroke() api in swift and using it on top of my Compose View nackground
i
Transparency is not supported in interop views. It won't be changed in short-term See my explanation in the previous thread - https://kotlinlang.slack.com/archives/C0346LWVBJ4/p1742458773528449?thread_ts=1742395588.034329&cid=C0346LWVBJ4 Issue to track - CMP-3154
s
ahh, thanks for replying! 🙂
d
This idea is a hack, but maybe you could draw the swift view on top of the compose view in the host view controller, and sync it using Modifier.onGloballyPositioned (making the compose version just a transparent Box) by writing to some sort of view position registry CompositionLocal and make that set the swift view's location to match?