Iphone 类似Facebook的登录屏幕和验证(窗口抖动效果)
我需要我的登录屏幕如下所示 在Iphone 类似Facebook的登录屏幕和验证(窗口抖动效果),iphone,objective-c,facebook,Iphone,Objective C,Facebook,我需要我的登录屏幕如下所示 在facebook登录中,如果您将用户名或密码字段留空并单击登录按钮,则user name和password字段会振动(如抖动) 这是怎么做到的 您可以使用Cabasicanization实现这一点。看看这个 对于cocoa应用程序,请查看 -(CAKeyframeAnimation*)shakeAnimation:(NSRect)帧 { int numberOfShakes=4; 浮动持续时间为0.2f; 浮子振动强度=0.04f; CAKeyframeAnimat
facebook
登录中,如果您将用户名或密码字段留空并单击登录按钮,则user name
和password
字段会振动(如抖动)
这是怎么做到的
您可以使用
Cabasicanization
实现这一点。看看这个
对于cocoa应用程序,请查看
-(CAKeyframeAnimation*)shakeAnimation:(NSRect)帧
{
int numberOfShakes=4;
浮动持续时间为0.2f;
浮子振动强度=0.04f;
CAKeyframeAnimation*shakeAnimation=[CAKeyframeAnimation动画];
CGMutablePathRef shakePath=CGPathCreateMutable();
CGPathMoveToPoint(shakePath,NULL,NSMinX(frame),NSMinY(frame));
整数指数;
对于(索引=0;索引
你认为这是怎么做到的?设置一些计时器,将字段向左移动一些像素,然后再向后移动,然后向右移动。我需要知道是使用了单元格还是标签。在我看来,它就像UITableView。分组,2行,可能以文本字段作为其视图。
CABasicAnimation *animation =
[CABasicAnimation animationWithKeyPath:@"position"];
[animation setDuration:0.05];
[animation setRepeatCount:8];
[animation setAutoreverses:YES];
[animation setFromValue:[NSValue valueWithCGPoint:
CGPointMake([lockView center].x - 20.0f, [lockView center].y)]];
[animation setToValue:[NSValue valueWithCGPoint:
CGPointMake([lockView center].x + 20.0f, [lockView center].y)]];
[[lockView layer] addAnimation:animation forKey:@"position"];
- (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame
{
int numberOfShakes = 4;
float durationOfShake = 0.2f;
float vigourOfShake = 0.04f;
CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animation];
CGMutablePathRef shakePath = CGPathCreateMutable();
CGPathMoveToPoint(shakePath, NULL, NSMinX(frame), NSMinY(frame));
int index;
for (index = 0; index < numberOfShakes; ++index)
{
CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) - frame.size.width * vigourOfShake, NSMinY(frame));
CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + frame.size.width * vigourOfShake, NSMinY(frame));
}
CGPathCloseSubpath(shakePath);
shakeAnimation.path = shakePath;
shakeAnimation.duration = durationOfShake;
return shakeAnimation;
}
[window setAnimations:[NSDictionary dictionaryWithObject:[self shakeAnimation:[window frame]] forKey:@"frameOrigin"]];
[[window animator] setFrameOrigin:[window frame].origin];