1. pod 導入Lottie框架
2、在需要的地方import Lottie
3.初始化
letstarView = AnimationView(name: "json名稱,不要.json后綴")//先將json動效放到項目中
4.加載動畫
self.view.addSubview(starView)
starView.snp.makeConstraints { (make) in
make.size.equalTo(CGSize.init(width: 150, height: 150))
make.top.equalTo(swipeableView.snp.top).offset(120)
make.right.equalTo(swipeableView.snp.right).offset(-60)
}
starView.loopMode = .playOnce//循環次數
5.執行動畫
niceView.play()//開始動畫
