动画UITextField以指示错误的密码 [英] animating UITextField to indicate a wrong password
本文介绍了动画UITextField以指示错误的密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将动画添加到 UITextField
,以指示与Facebook应用程序(登录屏幕)或Mac OS X登录框中的密码完全相同的错误密码?
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 ?
提前谢谢你。
推荐答案
类似的东西
-(void)shake:(UIView *)theOneYouWannaShake
{
[UIView animateWithDuration:0.03 animations:^
{
theOneYouWannaShake.transform = CGAffineTransformMakeTranslation(5*direction, 0);
}
completion:^(BOOL finished)
{
if(shakes >= 10)
{
theOneYouWannaShake.transform = CGAffineTransformIdentity;
return;
}
shakes++;
direction = direction * -1;
[self shake:theOneYouWannaShake];
}];
}
所以你还需要三件事:一个int方向,之前设置为1摇动被称为int shakes,在调用抖动之前设置为0,并且持续MAX_SHAKES,它是您想要的大小。希望有所帮助。
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.
编辑:
这样称呼:
direction = 1;
shakes = 0;
[self shake:aUIView];
头文件内添加
int direction;
int shakes;
这篇关于动画UITextField以指示错误的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文