Shake visual effect on iPhone (NOT shaking the device)

后端 未结 11 821
忘了有多久
忘了有多久 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:25

    Using Auto Layout, I adapted Chris Miles' answer but animated NSLayoutConstraints like this:

    NSLayoutConstraint *left  = ...
    NSLayoutConstraint *right = ...
    
    [UIView animateWithDuration:0.08 delay:0.0 options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionRepeat animations:^{
        [UIView setAnimationRepeatCount:3];
        left.constant  = 15.0;
        right.constant = 25.0;
        [self.view layoutIfNeeded];
    } completion:^(BOOL finished) {
        if (finished) {
            [UIView animateWithDuration:0.08 animations:^{
                left.constant  = 20.0;
                right.constant = 20.0;
                [self.view layoutIfNeeded];
            } completion:NULL];
        }
    }];
    

提交回复
热议问题