Files
zellyy-finance/ios/App/App/ViewController.swift.bak

70 lines
2.4 KiB
Swift

import UIKit
import Capacitor
import WebKit
class ViewController: CAPBridgeViewController {
private var splashView: UIView?
override func viewDidLoad() {
super.viewDidLoad()
//
setupSplashView()
//
NotificationCenter.default.addObserver(self, selector: #selector(webViewDidFinishLoad), name: NSNotification.Name(rawValue: "capacitorWebViewDidLoad"), object: nil)
}
private func setupSplashView() {
//
splashView = UIView(frame: self.view.bounds)
splashView?.backgroundColor = UIColor.white
//
let titleLabel = UILabel()
titleLabel.text = "젤리의 적자탈출"
titleLabel.font = UIFont.boldSystemFont(ofSize: 36)
titleLabel.textAlignment = .center
titleLabel.translatesAutoresizingMaskIntoConstraints = false
if let splashView = splashView {
self.view.addSubview(splashView)
splashView.addSubview(titleLabel)
NSLayoutConstraint.activate([
titleLabel.centerXAnchor.constraint(equalTo: splashView.centerXAnchor),
titleLabel.centerYAnchor.constraint(equalTo: splashView.centerYAnchor)
])
}
}
@objc private func webViewDidFinishLoad() {
//
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
UIView.animate(withDuration: 0.3, animations: {
self.splashView?.alpha = 0
}, completion: { _ in
self.splashView?.removeFromSuperview()
self.splashView = nil
})
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
//
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
if self.splashView != nil && self.splashView?.alpha == 1 {
UIView.animate(withDuration: 0.3, animations: {
self.splashView?.alpha = 0
}, completion: { _ in
self.splashView?.removeFromSuperview()
self.splashView = nil
})
}
}
}
}