Learn Courses My Dashboard

Image slider .top .frame issue

The issues i have with this current code is that the imageslider does not .ignoresafearea(.top) in the simulator but it does ignore the safearea in the preview of the app. There’s a frame to my slider to make it appear on the top of the screen, since this is the way i learnt how to do it. So is it possible to make the imageslider .ignoresafearea (.top)?

Second problem, the imageslider have autoscroll with timer, and it resets on picture 1 once it on picture 3. But i can’t manually overpass the scroll from the 3rd picture to the 1st, what’s the problem?

Third, and last problem, i would like to have the timer to reset once i manually drag from one picture to another, (from 0) cause i’ve noticed that if i drag on the 4 second and then it directly passes another photo, making it unsmooth. How can i fix this problem?

Thanks :slight_smile:

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



                // overlay(Color.black.opacity(0)) if relevant



          .frame(width: proxy.size.width, height:   proxy.size.height / 3).ignoresSafeArea(.all, edges: .top)

            .onReceive(timer, perform: { _ in
                withAnimation {
                currentIndex = currentIndex < numberOfImages ? currentIndex + 1 : 0




struct Tab1_Previews: PreviewProvider {
    static var previews: some View {

  } ```