Reputation: 142
I'm working on a basic app for live photos and try to build user interface on SwiftUI. However, I don't understand how to display Live Photos properly. Is it possible to incorporate PHLivePhotoView into SwiftUI?
Upvotes: 3
Views: 1171
Reputation: 142
As @Asperi mentioned, UIViewRepresentable wrapper is a way to go:
import SwiftUI
import PhotosUI
struct LivePhotoView: UIViewRepresentable {
@Binding var livephoto: PHLivePhoto
func makeUIView(context: Context) -> PHLivePhotoView {
return PHLivePhotoView()
}
func updateUIView(_ lpView: PHLivePhotoView, context: Context) {
lpView.livePhoto = livephoto
}
}
Upvotes: 2