// 相机抖动
- (void)initxjIconAni{
//实例化
self.xjIconAni = [CAKeyframeAnimation animation];
//拿到动画key
self.xjIconAni.keyPath=@"transform.rotation";
//动画时间
//anim.duration=.50;
//重复的次数
//anim.repeatCount = 16;
//无限次重复
self.xjIconAni.repeatCount=3;
//设置抖动数值
self.xjIconAni.values=@[@(ANGLE_TO_RADIAN(-10)),@(ANGLE_TO_RADIAN(10)),@(ANGLE_TO_RADIAN(-10))];
//保持最后的状态
self.xjIconAni.removedOnCompletion=YES;
//动画的填充模式
self.xjIconAni.fillMode=kCAFillModeForwards;
NSMethodSignature *signature = [[self class] instanceMethodSignatureForSelector:@selector(xjIconTimered:)];
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature];
invocation.target=self;
invocation.selector=@selector(xjIconTimered:);
self.xjIconTimer = [NSTimer scheduledTimerWithTimeInterval:3 invocation:invocation repeats:YES];
}
- (void)startXjAniFunc{
//layer层实现动画
[self.camerIconImage.layer addAnimation:self.xjIconAni forKey:@"shake"];
}
- (void)xjIconTimered:(NSTimer*)timer {
[self startXjAniFunc];
}
网友评论