https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
p

Piotr Bartkowiak

03/15/2024, 2:28 PM
Hello, is it possible right now to remove the background from the view passed in UIKitView in compose? I tried adding a transparency background in the modifier, in the background, but nothing helped
Copy code
UIKitView(
    modifier = Modifier.background(Color.Transparent),
    background = Color.Transparent,
    factory = { someIconFactory() }
)
I also tried adding configuration to the ComposeUiViewController:
Copy code
ComposeUIViewController(configure = { opaque = false }) {
that didn't help either
t

tylerwilson

03/15/2024, 2:51 PM
I just dealt with the ComposeUIViewController case, and the opaque = false worked for me. But there may be other views in the hierarchy that you have to set backgroundColor to .clear. For the UIKitView case, I would check that the someIconFactory has the background set the way you want. "Debug ViewHierarchy" in XCode is your friend here.
👍 1
For example, I am putting a ComposeUIViewController into a parent UIViewController as a container, so I have also do the following:
Copy code
child.view.backgroundColor = .clear
        view.backgroundColor = .clear
where child is the wrapped ComposeView and view is the UIViewController I am creating and showing from other areas of my app.
👍 1
p

Piotr Bartkowiak

03/18/2024, 9:34 AM
Hi, thank you very much for your answer and tips, Its strange coz I removed background from iOS chromecast icon for iOS but It still has a black background in the composeContainer.. Im rendering some image on that view and I want chromecast icon to be on the top of that image and take on the background color of this image. See screenshoots below
t

tylerwilson

03/18/2024, 3:46 PM
If you can see that in the Xcode view hierarchy, it is likely not a compose issue, but an issue with your image or its rendering mode or its backgroundColor
2 Views