获得徽章 0
在SwiftUI中展示吐司的一种简单方法

嘗試使用這個開源:
github.com
我發現它很容易使用。

struct ContentView: View {
@State private var isShowingToast = false

var body: some View {
VStack(spacing: 20) {
Button("Show toast") {
self.isShowingToast = true
}

Spacer()
}
.padding()

// Just add a modifier to show a toast, with binding variable to control
.toast(isPresenting: $isShowingToast, dismissType: .after(3)) {
ToastView(message: "Hello world!", icon: .info)
}
}
}
展开
评论
个人成就
文章被阅读 868
掘力值 18
收藏集
6
关注标签
0
加入于