SwiftUI实战

SwiftUI实战-隐私政策和用户协议弹窗

2022-04-25  本文已影响0人  ISwiftUI

在实际的开发中,常常需要用户同意用户协议和隐私政策才可以正常的使用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()
    }
}
上一篇 下一篇

猜你喜欢

热点阅读