CABasicAnimation 左右两边抖动,中间位置不变

    CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

    

    //设置抖动幅度

    shake.fromValue = [NSNumber numberWithFloat:-0.1];

    

    shake.toValue = [NSNumber numberWithFloat:+0.1];

    

    shake.duration = 0.1;

    

    shake.autoreverses = YES; //是否重复

    

    shake.repeatCount = 4;

    

    [self.imageView.layer addAnimation:shake forKey:@"imageView"];

    

    self.imageView.alpha = 1.0;

    

    [UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionCurveEaseIn animations:nil completion:nil];

你可能感兴趣的:(CABasicAnimation 左右两边抖动,中间位置不变)