Tuesday, July 13, 2021

SwiftUI How to have sharesheet

 struct ShareSheetView: View {

    var body: some View {

        Button(action: actionSheet) {

            Image(systemName: "square.and.arrow.up")

                .resizable()

                .aspectRatio(contentMode: .fit)

                .frame(width: 36, height: 36)

        }

    }

    

    func actionSheet() {

        guard let data = URL(string: "https://www.zoho.com") else { return }

        let av = UIActivityViewController(activityItems: [data], applicationActivities: nil)

        UIApplication.shared.windows.first?.rootViewController?.present(av, animated: true, completion: nil)

    }

}

No comments:

Post a Comment