wallpaperAI/wallpaper_BProject/Main/NW_LauncVC.swift
2024-09-03 09:42:18 +08:00

60 lines
2.0 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// NW_LauncVC.swift
// wallpaper_BProject
//
// Created by 16 on 2024/9/2.
//
import UIKit
class NW_LauncVC: UIViewController {
private var progressView: UIProgressView!
private var timer: Timer?
private var progress: Float = 0.0
private let totalDuration: TimeInterval = 10.0
override func viewDidLoad() {
super.viewDidLoad()
setupProgressView()
startProgress()
}
private func setupProgressView() {
//
progressView = UIProgressView(progressViewStyle: .default)
progressView.frame = CGRect(x: 50, y: UIScreen.main.bounds.maxY - 36, width: self.view.frame.width - 100, height: 20)
progressView.progress = 0.0
progressView.tintColor = .black
progressView.trackTintColor = .lightGray
view.addSubview(progressView)
}
private func startProgress() {
//
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(updateProgress), userInfo: nil, repeats: true)
}
@objc private func updateProgress() {
//
let increment = 1.0 / Float(totalDuration)
if progress < 1.0 {
progress += increment
progressView.setProgress(progress, animated: true)
} else {
//
timer?.invalidate()
timer = nil
//
if let window = UIApplication.shared.windows.first {
//
let vc = NW_RootTabBarVC()
window.rootViewController = NW_RootNAVC(rootViewController: vc)
// 使
window.makeKeyAndVisible()
}
}
}
}