Hi so my image slider does not ignore my safearea(.top), and i can’t seem to get it fixed no matter what i do. Any suggestions? And also, my slider does not let me manually slide from picture three to the first (to start the cycle over again) and same when im on the first picture it won’t let me go to the third if i swipe left.
import SwiftUI
struct Tab1: View {
private var numberOfImages = 3
private let timer = Timer.publish(every: 10, on: .main, in: .common) .autoconnect()
@State private var currentIndex = 0
var body: some View {
GeometryReader { proxy in
TabView(selection:$currentIndex) {
ForEach(0..<numberOfImages) {num in
Image("\(num)")
.resizable()
.scaledToFill()
.overlay(Color.black.opacity(0.4))
.tag(num)
}
}.tabViewStyle(PageTabViewStyle())
.clipShape(RoundedRectangle(cornerRadius: 10))
.frame(width: proxy.size.width, height: proxy.size.height/ 3)
.onReceive(timer, perform: { _ in
withAnimation {
currentIndex = currentIndex <
numberOfImages ? currentIndex + 1 : 0
}
})
}
}
}
struct Tab1_Previews: PreviewProvider {
static var previews: some View {
Tab1()
}
}