我正在使用使用UIPageViewController行为的选项卡视图。所以我定义了以下模型:
class WalktroughModel: Identifiable, ObservableObject {
let id: UUID = UUID()
let imageName: String
let title: String
init(imageName: String, title: String) {
self.imageName = imageName
self.title = title
}
}
Run Code Online (Sandbox Code Playgroud)
现在我使用这个 swiftUI 视图作为选项卡视图的子视图:
struct WalktroughAsset: View {
@StateObject var asset: WalktroughModel
var body: some View {
Image(asset.imageName)
.resizable()
.overlay(Color.black.opacity(0.43))
.overlay(
VStack{
Spacer()
Text(asset.title)
.foregroundColor(.white)
.font(.custom("OpenSans-regular", size: 22.0))
}
.padding(.bottom, 64)
)
}
}
Run Code Online (Sandbox Code Playgroud)
在我的内容视图中,我有以下内容:
struct ContentView: View {
var thumbs: [WalktroughModel] = [WalktroughModel(imageName: "splash-1", title: "Concepto 1"), WalktroughModel(imageName: …Run Code Online (Sandbox Code Playgroud)