使用Lottie實(shí)現(xiàn)動(dòng)畫效果
1、通過CocoaPods lottie-ios導(dǎo)入這個(gè)類
2、找一個(gè)動(dòng)畫的json文件,Lottie不僅支持本地的json動(dòng)畫文件的播放,也支持網(wǎng)絡(luò)的json文件
3、代碼的實(shí)現(xiàn)
// LOTAnimationView *animationView = [[LOTAnimationView alloc]initWithContentsOfURL:[NSURL URLWithString:@"https://github.com/airbnb/lottie-ios/raw/master/Example/Assets/PinJump.json"]];
animationView.center = self.view.center;
animationView.frame = CGRectMake(0, 100, 300, 300);
animationView.contentMode = UIViewContentModeScaleAspectFill;
animationView.loopAnimation = true;
animationView.animationSpeed = 0.5;
[self.view addSubview:animationView];
// animationView.transform = CGAffineTransformMakeRotation(M_PI_4);;
[animationView play]; ```
在實(shí)現(xiàn)過程中遇到一個(gè)坑,引入了第三方庫,但是頭文件找不到,
找到:Build Settings > Search Paths >User Header Search Paths 添加${SRCROOT} 狀態(tài)改為recursive