我已经使用pod创建分页滚动:
https://github.com/fermoya/SwiftUIPager
但是,有些错误描述得不够充分。
我已创建
struct ContentView: View {
@State private var page = 0
...
}
self.levels = ["img1", "img2"...]
3。
struct cardView: View {
var item : String
@Binding var page: Int
let screenW = UIScreen.main.bounds.width
let screenH = UIScreen.main.bounds.height
let sceneButtonH = UIScreen.main.bounds.height * 0.6494
let sceneButtonW = (UIScreen.main.bounds.height * 0.6494) * 1.0867
let buttonPadding = ((UIScreen.main.bounds.height * 0.6494) * 1.0867) * 0.26
var body: some View{
Button(action: {
//self.showingDetail.toggle()
}) {
Image(uiImage: UIImage(named: item )!)
.renderingMode(.original)
.resizable()
.aspectRatio(contentMode: .fit)
.padding(.leading, buttonPadding/2)
.padding(.trailing, buttonPadding/2)
}
}
}
如何创建.identifier?这是一个自定义方法?
根据您的代码,假设self.level
为[String]
。如果是,请尝试使用id:\ .self
谢谢!