目录

SafariView

SafariView is a small Swift package for iOS that adds a SwiftUI bridge to SafariViewController.

Getting Started

SafariView can be easily installed through the Swift Package Manager in any Xcode project. To add SafariView to your package in Xcode 13, go to File › Swift Packages › Add Package Dependency… and paste in the URL: https://github.com/alicerunsonfedora/SafariView.

Example Usage

This example demonstrates how to open a SafariView when the user taps a button on iOS:

import SafariView
import SwiftUI

struct ExampleView: View {
    
    @State private var destination: URL = .init(string: "https://www.apple.com")
    @State private var showSafari: Bool = false

    var body: some View {
        VStack {
            Button {
                showSafari.toggle()
            } label: {
                Text("Go to Apple.com!")
            }
        }
        .sheet(isPresented: $showSafari) {
            SafariView(url: $destination)
                .collapsible(.constant(true))
        }
    }
}
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号