有没有办法在 SwiftUI 中使用 ProgressView 样式的自定义矩形?

问题描述 投票:0回答:0

随着倒数计时器的进行,我想通过降低我在 Zstack 中使用的矩形的高度来为图像提供进度效果。

这是我想要的图片中的进度:first second last.

当矩形高度每秒变化时,这种变化从顶部和底部框架发生like this.

ZStack {
                Image("apple")
                    .resizable()
                    .aspectRatio(contentMode: .fit)
                    .frame(width: 200, height: 200)
                    .padding()
                Rectangle()
                    .frame(width: 200, height: viewModel.height)
                    .foregroundColor(.white)
            }.onReceive(timer) { _ in
                  viewModel.height -= 1
            }
xcode swiftui progress-bar swiftui-animation zstack
© www.soinside.com 2019 - 2024. All rights reserved.