Shake visual effect on iPhone (NOT shaking the device)

后端 未结 11 822
忘了有多久
忘了有多久 2020-12-02 05:06

On login failure, I\'d prefer to avoid showing an alert, it\'s too fleeting. Showing the alert and then showing the text somewhere on the login screen seems like duplication

11条回答
  •  误落风尘
    2020-12-02 05:22

    Simply changing the X coordinate of the center property of your view might do the trick. If you haven't done any core animation before it's pretty straight-forward.

    First, start an animation right, then listen for it to finish, and then move back to the left, and so on. Getting the timing down so it "feels right" might take a while.

    - (void)animationFinishCallback:(NSString *)animationID finished:(BOOL)finished context:(void *)context
    {
      if ([animationID isEqualToString:@"MoveRight"]) {
        [UIView beginAnimations:@"MoveLeft" context:NULL];
        [UIView setAnimationDuration:1.0];
        [UIView setAnimationDelay: UIViewAnimationCurveEaseIn];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(animationFinishCallback:finished:context:)];
    
        myView.center = CGRectMake(newX, newY);
        [UIView commitAnimations];
      }
    }
    

提交回复
热议问题