BottomSheet-SwiftUI

SwiftUI 中的 BottomSheet 视图

基于: https://gist.github.com/mecid/78eab34d05498d6c60ae0f162bfd81ee

用法

import SwiftUI
import BottomSheet_SwiftUI

struct ContentView: View {
    @State private var bottomSheetOpened = false
    var body: some View {
        GeometryReader { geometry in
            Color.green
                .edgesIgnoringSafeArea(.all)
            BottomSheet(
                isOpen: self.$bottomSheetOpened,
                config: BottomSheetConfig(maxHeight: geometry.size.height * 0.9)
            ) {
                Color.white
            }
        }.edgesIgnoringSafeArea(.all)
    }
}

默认配置值

minHeightRatio: 0.2,
maxHeight: 300,
radius: 20,
indicatorSize: width: 100, height: 5,
snapRatio: 0.1,
indicatorColor: black,
indicatorBackgroundColor: white

安装

Swift Package Manager

BottomSheet-SwiftUI 与 SwiftPM 兼容。 要安装,请将此软件包添加到你的 Package.swift 文件或你的 Xcode 项目中。