With WWDC20, Apple added a new framework named PhotosUI to select images, videos etc from Library. In this tutorial, we going to implement the same with SwiftUI.
As PhotosUI is based on UIKit not SwiftUI, We need to write a representable. this representable can use PhotosUI’s “PHPickerViewController” in SwiftUI.
struct PhotoPicker: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> PHPickerViewController {
//init PHPickerViewController here
}
func updateUIViewController(_ uiViewController: PHPickerViewController, context: Context) {
}
func makeCoordinator() -> Coordinator {
//set delegates with Coordinator
}
}
Picker
#wwdc #programming #swiftui #swift #ios #photosui