在IOS开发中,避免不了和动画打交道
进度条动画
使用的是UIBezierPath 贝塞尔曲线画进度条及实现动画
进度条
仓库地址:https://xielei1029.coding.net/public/iosdonghuayongli/IOSAnimation/git/files
BargainProcessView文件
背景旋转
旋转.gif@property (assign,nonatomic)NSTimer* locationTimer;
@property (assign,nonatomic) CGFloat angle;
@property (strong,nonatomic)UIImageView * animationImageView;
self.locationTimer = [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector:@selector(transformAction) userInfo: nil repeats: YES];
-(void)transformAction {
self.angle = self.angle + 0.1;//angle角度 double angle;
if (self.angle > 6.28) {//大于 M_PI*2(360度) 角度再次从0开始
self.angle = 0;
}
CGAffineTransform transform = CGAffineTransformMakeRotation(self.angle);
self.animationImageView.transform = transform;
}
//开启定时器
[self.locationTimer setFireDate:[NSDate distantPast]];
//关闭定时器
[self.locationTimer setFireDate:[NSDate distantFuture]];
模仿蚂蚁森林收集能量
蚂蚁森林.gif仓库地址:https://xielei1029.coding.net/public/iosdonghuayongli/IOSAnimation/git/files
BDForestPowerView文件
起搏器效果
// 起搏器
+ (void)setPacceMakerAnimationButton:(UIButton*)sender{
sender.transform = CGAffineTransformIdentity;
[UIView animateKeyframesWithDuration:1.0 delay:0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations: ^{
[UIView addKeyframeWithRelativeStartTime:0 relativeDuration:1/2.0 animations: ^{
sender.transform = CGAffineTransformMakeScale(0.9, 0.9);
}];
[UIView addKeyframeWithRelativeStartTime:1/2.0 relativeDuration:1/2.0 animations: ^{
sender.transform = CGAffineTransformMakeScale(1.0, 1.0);
}];
} completion:nil];
}
网友评论