美文网首页
2021-11-25 iOS抖动动画

2021-11-25 iOS抖动动画

作者: cc帅气的昵称 | 来源:发表于2021-11-25 15:01 被阅读0次

// 相机抖动

- (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];

}

相关文章

网友评论

      本文标题:2021-11-25 iOS抖动动画

      本文链接:https://www.haomeiwen.com/subject/kmoatrtx.html