Core Animation
来源:互联网 发布:法国42编程学校 编辑:程序博客网 时间:2024/03/29 20:40
1:UIViewAnimationOptions
参考:http://blog.csdn.net/namehzf/article/details/7650416
typedef NS_OPTIONS(NSUInteger, UIViewAnimationOptions) { UIViewAnimationOptionLayoutSubviews = 1 << 0, UIViewAnimationOptionAllowUserInteraction = 1 << 1, // 允许视图在播放动画的时候 依旧触发事件 UIViewAnimationOptionBeginFromCurrentState = 1 << 2, // 从当前状态开始动画 UIViewAnimationOptionRepeat = 1 << 3, // 重复执行动画 UIViewAnimationOptionAutoreverse = 1 << 4, // 执行动画回路 UIViewAnimationOptionOverrideInheritedDuration = 1 << 5, // ignore nested duration UIViewAnimationOptionOverrideInheritedCurve = 1 << 6, // ignore nested curve UIViewAnimationOptionAllowAnimatedContent = 1 << 7, // animate contents (applies to transitions only) UIViewAnimationOptionShowHideTransitionViews = 1 << 8, // flip to/from hidden state instead of adding/removing UIViewAnimationOptionCurveEaseInOut = 0 << 16, // 由慢到快 UIViewAnimationOptionCurveEaseIn = 1 << 16, // 由慢到飞快 UIViewAnimationOptionCurveEaseOut = 2 << 16, // 由快到慢 UIViewAnimationOptionCurveLinear = 3 << 16, // 匀速展示动画 UIViewAnimationOptionTransitionNone = 0 << 20, // default UIViewAnimationOptionTransitionFlipFromLeft = 1 << 20, UIViewAnimationOptionTransitionFlipFromRight = 2 << 20, UIViewAnimationOptionTransitionCurlUp = 3 << 20, UIViewAnimationOptionTransitionCurlDown = 4 << 20, UIViewAnimationOptionTransitionCrossDissolve = 5 << 20, UIViewAnimationOptionTransitionFlipFromTop = 6 << 20, UIViewAnimationOptionTransitionFlipFromBottom = 7 << 20,} NS_ENUM_AVAILABLE_IOS(4_0);
1:View改变大小和位置
CGContextRef context = UIGraphicsGetCurrentContext();[UIView beginAnimations:nil context:context];[UIView setAnimationDuration:0.4];[UIView setAnimationDelegate:self];self.frame =CGRectMake(0,self.frame.size.height-44,self.frame.size.width,44);[UIView commitAnimations];
2:改变View的自身大小
CGAffineTransform tr = CGAffineTransformScale(self.transform, 0.55, 0.55); [UIView animateWithDuration:0.1 delay:0 options:0 animations:^{ self.transform = tr;} completion:^(BOOL finished) {}];
3:通过指定的线条确定动画轨迹
CGPoint fromPoint = CGPointMake(0, 0);UIBezierPath *movePath = [UIBezierPath bezierPath];[movePath moveToPoint:fromPoint];CGPoint toPoint = CGPointMake(300, 460);[movePath addQuadCurveToPoint:toPoint controlPoint:CGPointMake(toPoint.x,fromPoint.y)];//弧线 CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"]; moveAnim.path = movePath.CGPath; moveAnim.removedOnCompletion = NO; moveAnim.duration = 2; [moveAnim setRepeatCount:2]; [self.view1.layer addAnimation:moveAnim forKey:nil];
4: View 旋转180度
CGAffineTransformRotate(self.colTypeImageView.transform, 3.14 )
5:View 左右抖动动画
- (void) shakeAnimationWithControl:(UIView *)view { CAKeyframeAnimation *keyAn = [CAKeyframeAnimation animationWithKeyPath:@"position"]; [keyAn setDuration:0.5f]; NSArray *array = [[NSArray alloc] initWithObjects: [NSValue valueWithCGPoint:CGPointMake(view.center.x, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x-5, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x+5, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x-5, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x+5, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x-5, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x+5, view.center.y)], [NSValue valueWithCGPoint:CGPointMake(view.center.x, view.center.y)], nil]; [keyAn setValues:array]; NSArray *times = [[NSArray alloc] initWithObjects: [NSNumber numberWithFloat:0.1f], [NSNumber numberWithFloat:0.2f], [NSNumber numberWithFloat:0.3f], [NSNumber numberWithFloat:0.4f], [NSNumber numberWithFloat:0.5f], [NSNumber numberWithFloat:0.6f], [NSNumber numberWithFloat:0.7f], [NSNumber numberWithFloat:0.8f], [NSNumber numberWithFloat:0.9f], [NSNumber numberWithFloat:1.0f], nil]; [keyAn setKeyTimes:times]; [view.layer addAnimation:keyAn forKey:@"TextAnim"];}
6:切换ViewController或者将应用切换至后台时,动画不停止的方法
shake.removedOnCompletion = NO;
7:使用CAAnimation播放动画完后希望能适应新的坐标变化
[button.layer addAnimation:animationgroup forKey:@"Expand"];button.center = CGPointMake(button.center.x, button.center.y);
在加入动画以后, 直接设定 动画结束时的坐标即可.
- core animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core Animation
- Core animation
- Core Animation
- Core Animation
- Core Animation
- motionevent通过Shell执行touch或move事件
- 数据库字段取名为oracle数据库的关键字 :java.sql.SQLException: ORA-01747: user.table.column, table.column 或列说明无效
- 集智平台下拉数据集选值触发
- 第一次在项目中使用JQuery遇到的一点问题
- 省赛 总结
- Core Animation
- vi 复制粘贴
- Select模型与ioctlsocket的使用方法
- 举例说明什么是隐马尔科夫模型(HMM)
- 初学-之Oracle服务说明
- Adobe Flex 简介
- 开始吧
- 百度电话面试
- dotnet调java webservice C#调java webservice 头部验证 SoapHeader