点击某个按钮时候,晃动控件

在开发中,会遇到当输入框为空,但是用户提交信息的时候,这时候我们要给用户一个抖动提示用户。以下为方法:

if([self.searchTf.textisEqualToString:@""] ) {

[MBProgressHUDshowMessage:@"请输入搜索内容!"];

[selfloadShakeAnimationForView:self.searchTf];

}



//抖动方法

-(void)loadShakeAnimationForView:(UIView*)view

{

CALayer*lbl = [viewlayer];

CGPointposLbl = [lblposition];

CGPointy =CGPointMake(posLbl.x-10, posLbl.y);

CGPointx =CGPointMake(posLbl.x+10, posLbl.y);

CABasicAnimation* animation = [CABasicAnimationanimationWithKeyPath:@"position"];

[animationsetTimingFunction:[CAMediaTimingFunction

functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[animationsetFromValue:[NSValuevalueWithCGPoint:x]];

[animationsetToValue:[NSValuevalueWithCGPoint:y]];

[animationsetAutoreverses:YES];

[animationsetDuration:0.08];

[animationsetRepeatCount:3];

[lbladdAnimation:animationforKey:nil];

}


参考

http://blog.csdn.net/ios_dashen/article/details/50515464

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容