CustomAlertKit 支持 Swift Package Manager 和 CocoaPods。
要使用 Swift Package Manager 安装 CustomAlertKit,您可以按照 Apple 发布的 教程,使用仓库的 URL。
将 pod 添加到您的 Podfile
pod 'CustomAlertKit'
然后运行
pod install
将 cocoapod 安装到您的项目后,使用以下命令导入 CustomAlertKit:
import CustomAlertKit
@State var bottomsheetVisible = false
var body: some View {
...
}
.bottomSheet(visible: $bottomsheetVisible, background: .blur(.regular), contentBackgroundColor: .white) {
Text("This is a bottomsheet with blurred background")
.frame(height: 250)
}
}
@State var snackbarVisible = false
var body: some View {
...
}
.snackbar(visible: $snackbarVisible) {
Text("This is a snackbar")
.padding(16)
.background(.green)
.clipShape(Capsule())
}
}
@State var alertVisible = false
var body: some View {
...
}
.alert(visible: $alertVisible, background: .color(.black.opacity(0.4))) {
VStack {
Text("This is an alert with opaque background")
Button(action: {
withAnimation {
alertVisible.toggle()
}
}, label: {
Text("Close")
})
}
.padding(32)
.background(.red)
}
}
CustomAlertKit 要求 iOS 15 部署目标,并且仅与 SwiftUI 兼容。
CustomAlertKit 在 MIT 许可证下可用。 有关更多信息,请参见 LICENSE 文件。