I’m trying to add a PresentationButton to a view CardView that contains some Text and Image. Code is shown below:
PresentationButton(destination: ProfileHost()) {
CardView()
}
Here is my CardView implementation:
struct CardView : View {
@State var isCover = false
var cardFrame: (Length, Length) = (246.0, 391)
var fillColor = Color(red: 69/255, green: 60/255, blue: 201/255, opacity: 0.7)
var body: some View {
ZStack {
Image("image_large") // This is the image that disappears
.resizable()
CoverView(fillColor: fillColor)
.opacity(isCover ? 1:0)
}
.frame(width: cardFrame.0, height: cardFrame.1)
.cornerRadius(10)
}
}
As soon as I run the preview, the CardView turns blue and the image disappears. All the text stays unaffected. I thought this had something to do with the accentColor which I promptly switched to Color.clear - this had no effect on the image (it was still gone) but did get rid of the blue color. Any ideas?
You may want to add rederingMode to the image as follows :
PresentationButton(destination: CardStack()) {
Image("breast_image")
.renderingMode(.original)
.padding()
}
Btw, it's not a bug, the Button view tries to use the supplied image as a template (to render button states) and it needs to know that your image should be rendered as an actual image instead.
Please add the modify parameter .buttonStyle(.plain) to Button. In the given case the code has to be
PresentationButton(destination: ProfileHost()) {
CardView()
}.buttonStyle(.plain)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With