在实际的开发中,常常需要用户同意用户协议和隐私政策才可以正常的使用App
效果图:
隐私政策弹窗.png
相关源码如下
ContentView.swift
import SwiftUI
struct ContentView: View {
@State private var isPresented = false
var body: some View {
VStack {
Text("隐私政策")
.padding(.top, 100)
.foregroundColor(Color.blue)
HStack {
Spacer()
}
Spacer()
}.showPrivacyPolicyView(isPresented: $isPresented, action: { string in
isPresented = false
debugPrint(string)
})
.background(Color.gray)
.edgesIgnoringSafeArea(Edge.Set.all)
.onAppear {
isPresented = true
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
网友评论