I'm trying to wrap PHLivePhotoView with UIViewRepresentable. When I put the view in ScrollView, its height gets close to zero. I have to explicit the view size with frame(width:height:) modifier to make it visible.
( When I put it in VStack, it will displayed correctly. )
import SwiftUI
import PhotosUI
struct LivePhotoView: UIViewRepresentable {
let livePhoto: PHLivePhoto
func makeUIView(context: Context) -> PHLivePhotoView {
return PHLivePhotoView(frame: .zero)
}
func updateUIView(_ livePhotoView: PHLivePhotoView, context: Context) {
livePhotoView.livePhoto = livePhoto
}
}
import SwiftUI
import PhotoKit
struct ContentView: View {
@Binding var photos:[PHLivePhoto] = []
var body: some View {
ScrollView { //👈🏼
ForEach(photos, id: \.self) { photo in
PHLivePhotoView(livePhoto: photo)
}
}
}
}
How can I make LivePhotoView work without size specification, like SwiftUI.Image ?