/**
* UILabel抖动效果
*/
-(void)lockAnimationForView:(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];
}
UILabel抖动动画实现
本文介绍了一种在iOS开发中实现UILabel抖动效果的方法。通过使用Core Animation框架下的CABasicAnimation类创建位置变化动画,并设置动画参数如timing function、autoreverses等属性来达到预期的抖动效果。
1万+

被折叠的 条评论
为什么被折叠?



