I am a developer

Shake view animation

-(void)shakeView {
    
    CABasicAnimation *shake = [CABasicAnimation animationWithKeyPath:@"position"];
    [shake setDuration:0.1];
    [shake setRepeatCount:2];
    [shake setAutoreverses:YES];
    [shake setFromValue:[NSValue valueWithCGPoint:
                         CGPointMake(view.center.x - 5,view.center.y)]];
    [shake setToValue:[NSValue valueWithCGPoint:
                       CGPointMake(view.center.x + 5, view.center.y)]];
    [view.layer addAnimation:shake forKey:@"position"];
    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

}

No comments:

Post a Comment