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.
Since the question was about Objective-C, and since I am using Objective-C in my project, I think this Objective-C translation of this previous Swift answer could be useful to someone else:
If you came here looking for a MonoTouch answer, here is a rough translation of Dickey's code:
Put it with the rest of your extensions methods and call like that:
(Jan 16 2015) Update: (enum UIViewAnimationOptions) cast is fine and UIViewAnimationOptionCurveEaseOut is 2 << 16 per UIView.h under typedef NS_OPTIONS(NSUInteger, UIViewAnimationOptions)
(Jan 31 2013) Further modified Kai's answer to include:
Note: if you plan on shaking two controls (email and password) together you might want to avoid using class or static variables for shakes and translate. Instead, initialize and pass shake and translate as parameters. I used statics so no class variables needed.
Something like that
So you need three more things: An int direction which is set to 1 before the shake is called an int shakes, which is set to 0 before the shake is called and a constant MAX_SHAKES which is as large as you like. Hope that helps.
EDIT:
call it like this:
inside header file add
Swift 3 and stack_view instaed textField
I created a category method for UIView that can be used to shake any element - e.g. a UITextField - with the ability to get notified after the shaking has ended. Here is how to use it:
Here is the code.
UIView+Shake.h
UIView+Shake.m