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.
So I'd like for it to graphically shake my login view when the user enters the wrong user ID and password like the Mac login screen does.
Anyone know if there's a way to pull this off, or have any suggestions for another effect I could use?
I think this is a more efficient solution:
Swift:
Obj-C:
Only one animation object is created and it's all performed at the CoreAnimation level.
Using Auto Layout, I adapted Chris Miles' answer but animated NSLayoutConstraints like this:
This UIView category snippet worked for me. It's using 3 CABasingAnimations applied to view's layer.
Hope it helpes someone :)
very easy shake categorie for UIVoew
https://github.com/jonasschnelli/UIView-I7ShakeAnimation
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.
In iOS 7.0 or later, UIKit keyframe animation is available.