struct ContentView: View { @State private var text = "" var body: some View { VStack { TextEditor(text: $text) ShareLink(item: "", subject: Text("DevTechie.com"), message: Text("Visit DevTechie.com for iOS Development Content!")) } } }
Note that subject and message are optional parameters
struct ContentView: View { let url = URL(string: "https://www.devtechie.com")! var body: some View { VStack { Text("DevTechie.com") ShareLink(item: url) } } }
struct ContentView: View { let url = URL(string: "https://www.devtechie.com")! var body: some View { VStack { Text("DevTechie") .font(.largeTitle) ShareLink(item: url) { Label("Visit DevTechie Website!", systemImage: "globe") .foregroundColor(.white) .padding() .background(.orange.gradient.shadow(.drop(radius: 1, x: 2, y: 2)), in: RoundedRectangle(cornerRadius: 5)) } } } }
struct Photo: Transferable { static var transferRepresentation: some TransferRepresentation { ProxyRepresentation(exporting: \.image) }public var image: Image public var caption: String }
struct ContentView: View { var imgToShare = Photo(image: Image("DT"), caption: "DevTechie.com") var body: some View { VStack { Text("DevTechie") .font(.largeTitle) ShareLink( item: imgToShare, preview: SharePreview( "DevTechie", image: imgToShare.image)) { Text("Share DevTechie.com") } } } }
With that we have reached the end of this article. Thank you once again for reading. Subscribe our newsletter at https://www.devtechie.com