控件抖动

来源:互联网 发布:显卡更新驱动负优化 编辑:程序博客网 时间:2024/05/18 11:50

传入一个控件可以控制其抖动

-(void)loadShakeAnimationForView:(UIView*)view{    CALayer *lbl = [view layer];    CGPoint posLbl = [lbl position];    CGPoint y = CGPointMake(posLbl.x-10, posLbl.y);    CGPoint x = CGPointMake(posLbl.x+10, posLbl.y);    CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"position"];    [animation setTimingFunction:[CAMediaTimingFunction                                  functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];    [animation setFromValue:[NSValue valueWithCGPoint:x]];    [animation setToValue:[NSValue valueWithCGPoint:y]];    [animation setAutoreverses:YES];    [animation setDuration:0.08];    [animation setRepeatCount:3];    [lbl addAnimation:animation forKey:nil];}




0 0
原创粉丝点击