PhotosPicker
是一个基于 PHPickerViewController
的照片选择器表单。目前仅支持 iOS 和 Mac Catalyst。
PhotosPicker
具有与其他 Presentation Modifiers 类似的 API 和行为。
import SwiftUI
import PhotosPicker
struct ContentView: View {
@State private var showingPicker = false
var body: some View {
Button("Choose image") {
showingPicker = true
}
.photosPicker(isPresented: $showingPicker) { photos in
if photos.count > 0 {
print("Selected \(photos)")
}
}
}
}
https://github.com/lorenzofiamingo/swiftui-photos-picker
) 并点击 Next (下一步)。