动画似乎叠加在桌子上,并且停止工作!视频显示,动画大小较小时,表格可以正常工作,但是当您添加动画大小时,表格将停止工作
https://drive.google.com/open?id=1nLm_uwt-AhIrJvib80lLh3ZqBH1b_SWY https://drive.google.com/open?id=15Cv4JvadTzJnB_MHG9ksCugnZqVcpgCc 源项目:https://drive.google.com/open?id=1eGDZ0Z0Wf_2co2lEV9KOWE4LISC5Vogw
import UIKit
import Lottie
class MainViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var tableView: UITableView!
let sportMenu = ["Начать тренировку","Выбрать другую","Советы по упражнениям"]
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return sportMenu.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")
cell?.textLabel?.text = sportMenu[indexPath.row]
return cell!
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
switch indexPath.row {
case 0:
performSegue(withIdentifier: "StartTraining", sender: nil)
default:
break
}
}
@IBOutlet weak var animation: UIView!
@IBOutlet weak var settingsIcon: UIBarButtonItem!
let animationView = AnimationView()
let size: CGFloat = 540
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.tableFooterView = UIView()
tableView.isScrollEnabled = false
navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .automatic
let animation = Animation.named("Espander")
animationView.animation = animation
animationView.play()
animationView.loopMode = .loop
animationView.frame = CGRect(x: 0, y: 0, width: size, height: size)
animationView.contentMode = .scaleAspectFit
view.addSubview(animationView)
animationView.translatesAutoresizingMaskIntoConstraints = false
animationView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: -120).isActive = true
animationView.heightAnchor.constraint(equalToConstant: size).isActive = true
animationView.widthAnchor.constraint(equalToConstant: size).isActive = true
animationView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
}
答案 0 :(得分:0)
您的animationView可能正在吸收水龙头,所以这就是tableView不响应的原因。
只需添加animationView.isUserInteractionEnabled = false