本篇内容为常见的首次打开APP时的提示引导页,通过下一步按钮切换展示不同引导页面最终打开主页面。
示例效果如下
实现代码示例
import SwiftUI
struct GuideView: View {
    
    @State var currentStep = 0
    @State var isFinished = false
    var body: some View {
        ZStack {
            if isFinished {
                HomeView()
                    .transition(.move(edge: .trailing))
            } else {
                VStack {
                    ProgressView(steps: guideSteps.count, currentStep: $currentStep)
                    Spacer()
                    GuideDescView(guideSteps: guideSteps, currentStep: currentStep)
                    Spacer()
                }
                .padding()
                NextButton(currentStep: $currentStep, color: guideSteps[currentStep].color) {
                    if currentStep < guideSteps.count - 1 {
                        currentStep += 1
                    } else {
                        
                        withAnimation(.linear) {
                            isFinished.toggle()
                        }
                    }
                }
            }
            
        }
    }
}
#Preview {
    GuideView()
}
完整代码下载
  本文自 https://www.codeun.com 发布,相应代码均自主编写并严格审阅和测试,完整代码中包含丰富的学习笔记和使用方式、实用技巧。
  · 如若转载,请注明出处:https://www.codeun.com/archives/1313.html ·
 
                