Open2

SwiftUIのS

phihashphihash

ShareLink

共有シートをだすView

基本構造

ShareLink(
  item: URL(string: "https://example.net")!,
  subject: Text("メールの件名とかになる"),
  message: Text("LINEに表示されたり、テキストになる(まさにメッセージ)")
) 

itemにわたせるもの。

説明
URL ⚠️ !をつけましょう
String メモやSNSなどでのテキスト共有
Image / UIImage 写真やスクリーンショット
Array<Any> 複数同時共有(例:URL+画像など)※通常はURL単体で十分

ShareLink(
    item: ..., 
    subject: ..., 
    message: ...
) {
    Label("このアプリを共有する", systemImage: "square.and.arrow.up")
}
phihashphihash

Label

アイコン付きテキスト

Label("設定", systemImage: "gear")
Label("送信", image: "custom_icon")

下記はより詳細なカスタムをしたい場合

Label {
    Text("プロフィール")
        .font(.headline)
} icon: {
    Image(systemName: "person.crop.circle")
}