TipKit: Change color of TipView close button?

Greetings,

I'm dipping a toe into TipKit and trying it out. I placed a TipView into one of my SwiftUI views, and the default styling didn't fit well within our app, so I changed the background and text colors. However, I can't find a way to change the color of the close button ("X"). Unfortunately, the default color is very hard to see against the background color that I selected.

Is it possible to set the color of that close button?

For the time being, I have created a TipViewStyle that replicates the default styling with my color changes applied, but this seems unnecessarily complex for something as simple as setting the color of that button.

Thanks!

Answered by themung in 791512022

Yes

    func makeBody(configuration: Configuration) -> some View {
            VStack(alignment: .leading) {
                HStack(alignment: .firstTextBaseline) {
...
                    Button(action: { configuration.tip.invalidate(reason: .tipClosed) }) {
                        Image(systemName: "xmark").scaledToFit().foregroundColor(.white)
                                    }
                }
                ...
            }
        }
}

Yes

    func makeBody(configuration: Configuration) -> some View {
            VStack(alignment: .leading) {
                HStack(alignment: .firstTextBaseline) {
...
                    Button(action: { configuration.tip.invalidate(reason: .tipClosed) }) {
                        Image(systemName: "xmark").scaledToFit().foregroundColor(.white)
                                    }
                }
                ...
            }
        }
}

Yes, thanks, I did mention that I created a TipViewStyle as a workaround. What I was hoping was that there might be a way to do this with a method on the default TipView, similar to tipBackground or tipCornerRadius.

It seems like an oversight that you can change the background color of the tip and change the color of the text and any icon, but not the color of the close button.

TipKit: Change color of TipView close button?
 
 
Q