-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShareSheet.swift
45 lines (38 loc) · 1.05 KB
/
ShareSheet.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Native Share Sheet in SwiftUI which can also be used with `presentationDetents`
import SwiftUI
struct ContentView: View {
var body: some View {
VStack(spacing: 14) {
SwiftAnytimeView()
Text("Like our work? Share with your friends!")
.font(.title3.bold())
ShareLink(item: URL(string: "https://www.swiftanytime.com")!) {
LabelView()
}.presentationDetents([.medium])
}
}
}
struct SwiftAnytimeView: View {
var body: some View {
Image("logo")
.resizable()
.scaledToFit()
.frame(width: 128, height: 128)
}
}
struct LabelView: View {
var body: some View {
Text("Share")
.frame(width: 60, height: 10)
.font(.headline)
.foregroundColor(.orange)
.padding()
.background(Color.orange.opacity(0.1))
.clipShape(Capsule())
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}