下面是我在SwiftUI中创建视图的代码。我想把我最下面的抽屉连接到屏幕底部。
struct BottomDrowerView: View {
@State private var offset: CGFloat = 100
var body: some View {
GeometryReader { proxy in
VStack{
}
}
.background(Color.red)
.offset(y: offset)
.gesture(
DragGesture()
.onChanged{ value in
let startLocation = value.startLocation
offset = startLocation.y + value.translation.height
}
)
}
}
我试过了,
.frame(maxHeight: .infinity, alignment: .bottom)
但它不起作用。