50 lines
1.3 KiB
Swift
50 lines
1.3 KiB
Swift
//
|
|
// MP_WaveAnimationMaskView.swift
|
|
// relax.offline.mp3.music
|
|
//
|
|
// Created by Mr.Zhou on 2024/8/9.
|
|
//
|
|
|
|
import UIKit
|
|
import Lottie
|
|
class MP_WaveAnimationMaskView: UIView {
|
|
///动画View
|
|
private lazy var lotView:LottieAnimationView = {
|
|
//获取动画View
|
|
let json = Bundle.main.path(forResource: "Wave_Animation", ofType: "json")
|
|
let animationView:LottieAnimationView = .init(filePath: json ?? "")
|
|
//无限循环
|
|
animationView.loopMode = .loop
|
|
//填充
|
|
animationView.contentMode = .scaleAspectFill
|
|
animationView.backgroundColor = .clear
|
|
return animationView
|
|
}()
|
|
init(frame: CGRect, cornerRadius:CGFloat) {
|
|
super.init(frame: frame)
|
|
backgroundColor = .init(hex: "#000000", alpha: 0.6)
|
|
layer.masksToBounds = true
|
|
layer.cornerRadius = cornerRadius
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
super.init(coder: coder)
|
|
}
|
|
//配置
|
|
func configure() {
|
|
addSubview(lotView)
|
|
lotView.snp.makeConstraints { make in
|
|
make.center.equalToSuperview()
|
|
make.width.height.equalToSuperview().multipliedBy(0.35)
|
|
}
|
|
}
|
|
//启动动画
|
|
func startAnimation() {
|
|
lotView.play()
|
|
}
|
|
//暂停动画
|
|
func stopAnimation() {
|
|
lotView.stop()
|
|
}
|
|
}
|