| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- //
- // QSLGuideController.swift
- // QuickSearchLocation
- //
- // Created by Destiny on 2024/12/9.
- //
- import UIKit
- import GKCycleScrollView
- class QSLGuideController: QSLBaseController {
-
- // var currentPage
-
- lazy var cycleScrollView: GKCycleScrollView = {
-
- let cycleScrollView = GKCycleScrollView()
- cycleScrollView.dataSource = self
- cycleScrollView.delegate = self
- cycleScrollView.isAutoScroll = false
- cycleScrollView.isInfiniteLoop = false
- cycleScrollView.isChangeAlpha = false
- cycleScrollView.pageControl = pageControl
- return cycleScrollView
- }()
-
- lazy var pageControl: GKPageControl = {
-
- let pageControl = GKPageControl()
- pageControl.style = .rectangle
- pageControl.dotHeight = 4.rpx
- pageControl.dotWidth = 20.rpx
- pageControl.dotMargin = 4.rpx
- pageControl.pageIndicatorTintColor = .hexStringColor(hexString: "#EEEEEE")
- pageControl.currentPageIndicatorTintColor = QSLColor.themeMainColor
- return pageControl
- }()
-
- lazy var nextButton: UIButton = {
-
- let btn = UIButton()
- btn.gradientBackgroundColor(color1: .hexStringColor(hexString: "#15CBA1"), color2: .hexStringColor(hexString: "#1FE0BA"), width: 280.rpx, height: 44.rpx, direction: .horizontal)
- btn.title("下一步")
- btn.mediumFont(16)
- btn.textColor(.white)
- btn.addRadius(radius: 22.rpx)
- btn.addTarget(self, action: #selector(nextBtnAction), for: .touchUpInside)
- return btn
- }()
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
- self.view.addSubview(cycleScrollView)
- cycleScrollView.snp.makeConstraints { make in
- make.left.equalTo(40.rpx)
- make.right.equalTo(-40.rpx)
- make.height.equalTo(368.rpx)
- make.top.equalTo(QSLConst.qsl_kStatusBarFrameH + 72.rpx)
- }
-
- self.view.addSubview(pageControl)
- pageControl.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 68.rpx, height: 4.rpx))
- make.centerX.equalToSuperview()
- make.top.equalTo(cycleScrollView.snp.bottom).offset(17.rpx)
- }
-
- self.view.addSubview(nextButton)
- nextButton.snp.makeConstraints { make in
- make.size.equalTo(CGSize(width: 280.rpx, height: 44.rpx))
- make.centerX.equalToSuperview()
- make.top.equalTo(pageControl.snp.bottom).offset(50.rpx)
- }
-
- cycleScrollView.reloadData()
- }
-
- // 点击下一步按钮
- @objc func nextBtnAction() {
-
- switch cycleScrollView.currentSelectIndex {
- case 0:
- gravityInstance?.track(QSLGravityConst.guide_first_click)
- break
- case 1:
- gravityInstance?.track(QSLGravityConst.guide_second_click)
- break
- case 2:
- gravityInstance?.track(QSLGravityConst.guide_third_click)
- break
- default:
- break
- }
-
- if cycleScrollView.currentSelectIndex == 2 {
- if let sceneDelegate = UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate {
- sceneDelegate.window?.rootViewController = CustomTabBarController()
- sceneDelegate.window?.makeKeyAndVisible()
- }
- } else {
- cycleScrollView.scrollToCell(at: cycleScrollView.currentSelectIndex + 1, animated: true)
- }
- }
- }
- extension QSLGuideController: GKCycleScrollViewDataSource, GKCycleScrollViewDelegate {
-
- func numberOfCells(in cycleScrollView: GKCycleScrollView!) -> Int {
- return 3
- }
-
- func cycleScrollView(_ cycleScrollView: GKCycleScrollView!, cellForViewAt index: Int) -> GKCycleScrollViewCell! {
- if let cell = cycleScrollView.dequeueReusableCell() {
- cell.imageView.image = UIImage(named: "guide_pic_\(index + 1)")
- return cell
- }
-
- let cell = GKCycleScrollViewCell()
- cell.imageView.image = UIImage(named: "guide_pic_\(index + 1)")
- return cell
- }
-
- func cycleScrollView(_ cycleScrollView: GKCycleScrollView!, didScrollCellTo index: Int) {
- switch index {
- case 0:
- gravityInstance?.track(QSLGravityConst.guide_first_show)
- break
- case 1:
- gravityInstance?.track(QSLGravityConst.guide_second_show)
- break
- case 2:
- gravityInstance?.track(QSLGravityConst.guide_third_show)
- break
- default:
- break
- }
- }
- }
|