MailView
允许你从 SwiftUI 发送邮件。你可以:
最终结果如下所示:
查看此教程,以获取组件及其代码的深入描述。查看 SwiftUIRecipes.com 以获取更多 SwiftUI 教程!
struct MailViewTest: View {
@State private var mailData = ComposeMailData(subject: "A subject",
recipients: ["i.love@swiftuirecipes.com"],
message: "Here's a message",
attachments: [AttachmentData(data: "Some text".data(using: .utf8)!,
mimeType: "text/plain",
fileName: "text.txt")
])
@State private var showMailView = false
var body: some View {
Button(action: {
showMailView.toggle()
}) {
Text("Send mail")
}
.disabled(!MailView.canSendMail)
.sheet(isPresented: $showMailView) {
MailView(data: $mailData) { result in
print(result)
}
}
}
}
此组件作为 Swift 包 分发。