头文件#import <QuartzCore/QuartzCore.h>
+(CABasicAnimation *) AlphaLight:(float)time
{
CABasicAnimation *animation =[CABasicAnimation animationWithKeyPath:@"opacity"];
animation.fromValue = [NSNumber numberWithFloat:1.0f];
animation.toValue = [NSNumber numberWithFloat:0.0f];//这是透明度。
animation.autoreverses = YES;
animation.duration = time;//动画循环的时间,也就是呼吸灯效果的速度
animation.repeatCount = MAXFLOAT;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
return animation;
}
//给指定元件添加动效:[yourUIView.layer addAnimation:[self AlphaLight:0.5] forKey:@"aAlpha"];
//移除动画:[_myView.layer removeAnimationForKey:@"aAlpha"];
原文地址:[http://v2it.win/ios/ios%E4%BC%9A%E5%91%BC%E5%90%B8%E7%9A%84%E5%8A%A8%E7%94%BB/](http://v2it.win/ios/ios%E4%BC%9A%E5%91%BC%E5%90%B8%E7%9A%84%E5%8A%A8%E7%94%BB/)
相关推荐(动画效果):http://blog.jobbole.com/69111/
网友评论