TabView(selection: $currentIndex) {
ForEach(1..<numberOfImages) { num in
Image("er\(num)")
.resizable()
.aspectRatio(contentMode: .fit)
//.scaledToFit()
// adding animation...
//.frame(height: self.num == num ? 200 : 240)
.cornerRadius(15)
.overlay(Color.black.opacity(0.4)).cornerRadius(15)
// for identifying current index....
.tag(num)
}
.scaledToFit()
.aspectRatio(contentMode: .fit)
}
.frame(height: 200)
.tabViewStyle(PageTabViewStyle())
TabView(selection: $currentIndex) {
ForEach(1..<numberOfImages) { num in
Image("er\(num)")
.resizable()
.aspectRatio(contentMode: .fill)
.frame(height: 200)
.cornerRadius(15)
.overlay(Color.black.opacity(0.4)).cornerRadius(15)
.padding([.leading, .trailing], 10)
.tag(num)
}
}
.frame(height: 200)
.tabViewStyle(PageTabViewStyle())
.padding()