美文网首页
点击某个按钮时候,晃动控件

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

作者: 隔壁老鹿 | 来源:发表于2017-06-19 13:54 被阅读0次

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

    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

    相关文章

      网友评论

          本文标题:点击某个按钮时候,晃动控件

          本文链接:https://www.haomeiwen.com/subject/icvgqxtx.html