how can I add an animation to a UITextField
to indicate wrong password exactly like the one in facebook app (at login screen) or the Mac OS X login box ?
thank you in advance.
how can I add an animation to a UITextField
to indicate wrong password exactly like the one in facebook app (at login screen) or the Mac OS X login box ?
thank you in advance.
You can also do it using basic animation
Here you can the change
duration
,repeatCount
.Changing into thefromValue
andtoValue
will change distance moved in the shakeThere's a Swift Library for animating Textfield in github here. Simply import the swift file and implement as below
Based on a previous answer as swift method ready to use :
To call it :
This Swift 2.0 answer requires no recursion and no loops. Just leverages
CABasicAnimation
by refining this SO answer:Updated for Swift 4:
I tried @stefreak solution but the loop approach doesn't work on iOS 7.1. So I combined the solutions from @stefreak and @Chris, and added the completion block to be notified when the shaking finishes. Here is my code:
Here's my spin on it: