我正在尝试在一个包含一些文本和图像的视图CardView中添加一个PresentationButton。以下是代码:
PresentationButton
。
PresentationButton(destination: ProfileHost()) {
CardView()
}
这是我的CardView实现:
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)
}
}
当我运行预览时,CardView变成蓝色并且图像消失了。所有文本保持不变。我认为这与accentColor
有关,于是我立即将其更改为Color.clear
- 这对图像没有影响(它仍然消失了),但却消除了蓝色。有什么想法吗?
CardView
实现得怎么样了? - Matteo Pacini