[ad_1]
I’m attempting to make a slideshow of textual content in TabView however I get this error
Can not convert worth of sort ‘[String]’ to anticipated argument sort
‘Int’
full code:
let numberText = ["1","2","3","4"]
struct TextNew: View {
non-public let timer = Timer.publish(each: 3, on: .fundamental, in: .widespread).autoconnect()
@State non-public var Index = 0
var physique: some View {
GeometryReader { proxy in
TabView(choice: $Index) {
ForEach(numberText, id: .self) { num in
Textual content("(numberText)")
.font(.system(dimension: 10))
.foregroundColor(.white)
.tag(num)
.padding(.backside, 50)
}
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .by no means))
.body(peak: 80)
.onReceive(timer) { _ in
withAnimation {
Index = Index < numberText ? Index + 1 : 0
}
}
}
}
}
[ad_2]
