类似Mac 登录不成功的shake效果

-(void) shake {
    // "Shakes" similar to OS X login screen
    CGAffineTransform moveRight = CGAffineTransformTranslate(CGAffineTransformIdentity, 20, 0);
    CGAffineTransform moveLeft = CGAffineTransformTranslate(CGAffineTransformIdentity, -20, 0);
   
    [UIView animateWithDuration:0.1 animations:^{
        // Translate left
        self.transform = moveLeft;
       
    } completion:^(BOOL finished) {
       
        [UIView animateWithDuration:0.1 animations:^{
           
            // Translate right
            self.transform = moveRight;
           
        } completion:^(BOOL aFinished) {
           
            [UIView animateWithDuration:0.1 animations:^{
               
                // Translate left
                self.transform = moveLeft;
               
            } completion:^(BOOL afinished) {
               
                [UIView animateWithDuration:0.1 animations:^{
                   
                    // Translate to origin
                    self.transform = CGAffineTransformIdentity;
                }];
            }];
           
        }];
    }];
}

你可能感兴趣的:(mac)