Post

Replies

Boosts

Views

Activity

Reply to How change videoGravity of VideoPlayer in SwiftUI
You should be able to use .aspectRatio(CGSize(width: 9, height: 16), contentMode: .fill) If VideoPlayer is within a ZStack it will try to take as much room as possible. In some instance, when I am layering content on top of a video, you need to make the VideoPlayer the background of the view. var body: some View { ZStack { VStack { Text("Hello") .frame(maxWidth: .infinity, alignment: .leading) .background(Color.red) Spacer() } } .background( VideoPlayer(player: AVPlayer(url: URL(string: "url")!)) .aspectRatio(CGSize(width: 9, height: 16), contentMode: .fill) .ignoresSafeArea() ) }
Aug ’23