I want to show some images in pageTabView.But the image size image is compressed. How do I control the size. My image is requested from the server.
struct TextView: View {
var body: some View {
ScrollView(.vertical, showsIndicators: false) {
VStack(spacing: 0) {
BannerView()// <- how to set size?
Text("aaaa")
}
}
}
}
struct BannerView: View {
var body: some View {
TabView() {
ForEach(0..<3) { index in
VStack{
Image(systemName: "pencil")
.resizable()
.scaledToFit()
.tag(index)
}.background(Color.blue)
}
}
.tabViewStyle(PageTabViewStyle())
.indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always))
}
}
Use .frame(height: yourDesiredHeight)
. However this will keep your image scaled as if you're using .scaleToFit()
which will try to fit all of the image in the frame.
Try using .aspectRatio(contentMode: .fill)
to fill the whole frame.