IOS layer常用动画
来源:互联网 发布:青岛网络干部学院 编辑:程序博客网 时间:2024/05/17 09:43
项目中总是需要用到一些动画效果
代码复制过来复制过去找起来很麻烦,直接粘上来以后好找。有的是网上找的,时间久了已经记不得出处了。有人知道就帮忙说下,我好粘帖下别人的链接。
1.过度动画 就是view的渐变效果,偷懒经常使用渐变效果。
#pragma mark - 过度动画-(void) GuoDuAnimation:(UIView *)view{ CATransition *animation = [CATransition animation]; animation.duration = 0.5; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; animation.type = @"Fade"; animation.subtype = kCATransitionFromLeft; [view.layer addAnimation:animation forKey:nil]; /* suckEffect(三角) rippleEffect(水波抖动) pageCurl(上翻页) pageUnCurl(下翻页) oglFlip(上下翻转) */}
2.移动动画
#pragma mark ===== 横向、纵向移动 ===========-( CABasicAnimation *)moveX:( float )time X:( NSNumber *)x{ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath : @"transform.translation.x" ]; ///.y 的话就向下移动。 animation. toValue = x; animation. duration = time; animation. removedOnCompletion = NO ; //yes 的话,又返回原位置了。 animation. repeatCount = MAXFLOAT ; animation. fillMode = kCAFillModeForwards ; return animation; }
3.闪烁动画
#pragma mark === 永久闪烁的动画 ======-(CABasicAnimation *)opacityForever_Animation:( float )time{ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath : @"opacity" ]; // 必须写 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; }
4.缩放动画
#pragma mark ===== 缩放 -=============-( CABasicAnimation *)scale:( NSNumber *)Multiple orgin:( NSNumber *)orginMultiple durTimes:( float )time Rep:( float )repertTimes{ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath : @"transform.scale" ]; animation. fromValue = Multiple; animation. toValue = orginMultiple; animation. autoreverses = YES ; animation. repeatCount = repertTimes; animation. duration = time; // 不设置时候的话,有一个默认的缩放时间 . animation. removedOnCompletion = NO ; animation. fillMode = kCAFillModeForwards ; return animation; }
5.组合动画
#pragma mark ===== 组合动画 -=============-( CAAnimationGroup *)groupAnimation:(NSArray *)animationAry durTimes:(float)time Rep:(float)repeatTimes{ CAAnimationGroup *animation = [CAAnimationGroup animation]; animation. animations = animationAry; animation. duration = time; animation. removedOnCompletion = NO ; animation. repeatCount = repeatTimes; animation. fillMode = kCAFillModeForwards ; return animation; }
6.路径动画
#pragma mark ===== 路径动画 -=============-( CAKeyframeAnimation *)keyframeAnimation:(CGMutablePathRef )path durTimes:(float)time Rep:(float)repeatTimes{ CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath : @"position" ]; animation. path = path; animation. removedOnCompletion = NO ; animation. fillMode = kCAFillModeForwards ; animation. timingFunction = [CAMediaTimingFunction functionWithName : kCAMediaTimingFunctionEaseIn ]; animation. autoreverses = NO ; animation. duration = time; animation. repeatCount = repeatTimes; return animation; }
7.旋转动画
#pragma mark ==== 旋转动画 ======-( CABasicAnimation *)rotation:( float )dur degree:( float )degree direction:( int )direction repeatCount:( int )repeatCount{ CATransform3D rotationTransform = CATransform3DMakeRotation (degree, 0 , 0 , direction); CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath : @"transform" ]; animation. toValue = [ NSValue valueWithCATransform3D :rotationTransform]; animation. duration = dur; animation. autoreverses = NO ; animation. cumulative = NO ; animation. fillMode = kCAFillModeForwards ; animation. repeatCount = repeatCount; animation. delegate = self ; return animation; }
后续有用的再添加...
0 0
- IOS layer常用动画
- iOS Layer动画收集
- 复习iOS动画-layer
- iOS动画 ---特殊Layer动画
- iOS动画 ---特殊Layer动画
- IOS UIVIEW layer动画 总结
- iOS Layer动画的KeyPath
- IOS UIVIEW layer动画 总结
- iOS-动画 之 Layer(1)
- 复习iOS动画-layer-2
- 复习iOS动画-layer-3
- 复习iOS动画-layer-4
- 复习iOS动画-Layer Time
- IOS 雷达效果(Layer的动画)笔记
- iOS动画——Layer Animations(一)
- iOS动画——Layer Animations(二)
- iOS动画——Layer Animations
- ios layer 动画-transform.rotation
- getResource().getPath() 路径带 问题展开
- ORA-01691: unable to extend lob segment 问题解决
- Eclipse中的svn冲突解决办法
- JS中的JSON转换
- Js也有console对象,在控制台打印调试再好不过
- IOS layer常用动画
- jQuery的三种bind/One/Live事件绑定使用方法
- 【整】jquery $(document).ready() 与window.onload的区别
- regSvr32 脚本注册避开“以管理员身份运行”权限注册失败的解决方法
- 【转】Bat 脚本学习
- 李开复:如何设计你的2015年度计划
- Enter键表单自动提交问题
- 谈谈javaScript 的trim()方法
- Java随机数的几种有趣用法