Visual_Novel_iOS/crush/Crush/Src/Components/UI/Hud/AnimatingView.swift

57 lines
1.2 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.

//
// AnimatingView.swift
// Crush
//
// Created by Leon on 2025/8/23.
//
import UIKit
import APNGKit
enum AnimatingViewType {
case generating
}
/// APNGloadingViewAPNG
class AnimatingView: UIView{
var iv : APNGImageView!
var type: AnimatingViewType = .generating
private override init(frame: CGRect) {
super.init(frame: frame)
}
convenience init(type: AnimatingViewType = .generating) {
self.init(frame: .zero)
self.type = type
setupViews()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupViews() {
backgroundColor = .clear
iv = {
let v = APNGImageView()
v.contentMode = .scaleAspectFit
addSubview(v)
v.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
return v
}()
switch type {
case .generating:
if let url = Bundle.main.url(forResource: "generating", withExtension: "png") {
let image = try? APNGImage(fileURL: url)
iv.image = image
}
}
}
}