按钮点击时图像没有改变。
我在资产文件夹中有 100 多张图片。如何迭代这些图像?
import SwiftUI
struct ContentView: View {
@State var tapCounter:Int = 1
@State var images = [Image(systemName: "1_ArRehmanu"),Image(systemName: "3_AlMaliku"),
Image(systemName: "4_AlQudoos"),Image(systemName: "1_ArRehmanu"),Image(systemName: "3_AlMaliku"),Image(systemName: "4_AlQudoos"),Image(systemName: "3_AlMaliku"),
Image(systemName: "4_AlQudoos")]
var body: some View {
NavigationView{
VStack{
Spacer()
Button(action:{
self.tapCounter += 1
ForEach(0..<images.count){value in (images[value])
.resizable()
.foregroundColor(Color.black)
.frame(width:330, height:330)
.padding()
}
},
label:{
Text("Start")
.frame(width: 250
, height: 60, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.foregroundColor(.white)
.background(Color.black)
.cornerRadius(8.0)
.padding()
})
Text("\(tapCounter) times")
.navigationTitle("Ninty Nine Names Of Allah")
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
}