动画杂记
来源:互联网 发布:淘宝靠谱的三星手机店 编辑:程序博客网 时间:2024/06/07 17:53
1.在UIView的基础上:
UIGraphicsBeginImageContext(CGSizeMake(320,460));
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(ctx, [UIColor whiteColor].CGColor);
CGContextAddArc(ctx, 160, 240, 100, 0, 2*M_PI, 1);
CGContextDrawPath(ctx, kCGPathStroke);
UIImage *curve = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
imageView.image = curve;
[self addSubview:imageView];
2.使用UIBezierPathUIBezierPath *patha=[UIBezierPath bezierPath];
CGRect recta=[UIScreen mainScreen].applicationFrame;
[patha addArcWithCenter:CGPointMake(recta.size.width/2,recta.size.height/2-130) radius:65 startAngle:0 endAngle:2*M_PI clockwise:NO];
CAShapeLayer *arcLayera=[CAShapeLayer layer];
arcLayera.path=patha.CGPath;//46,169,230
arcLayera.fillColor=[UIColor whiteColor].CGColor;
arcLayera.strokeColor=[UIColor grayColor].CGColor;
arcLayera.lineWidth=2;
arcLayera.frame=self.view.frame;
[self.view.layer addSublayer:arcLayera];
使uiimageView转动的轨迹为圆(围绕固定点转动)//初始化ImageView(我这儿是使用UIbeziePath画了一个圆点)
IImageView *circleView1 = [[UIImageView alloc] init];
[circleView1.layer addSublayer:arcLayer];
[self.view addSubview:circleView1];
circleView1.frame = CGRectMake(recta.size.width/2,recta.size.height/2-130, 30, 30);
//设置动画的属性
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
pathAnimation.duration = 0.5;
pathAnimation.repeatCount = 1000;
//设置运转动画的路径
CGMutablePathRef curvedPath = CGPathCreateMutable();
CGPathAddArc(curvedPath, NULL, recta.size.width/2+15,recta.size.height/2-115, 62, M_PI / 8, M_PI / 8 + 2 * M_PI, 0);
pathAnimation.path = curvedPath; CGPathRelease(curvedPath);
//给UIImageVIew添加旋转轨迹
[circleView1.layer addAnimation:pathAnimation forKey:@"moveTheCircleOne"];- 动画杂记
- ue4 动画相关方法杂记
- AngularJS杂记11----angularJS动画实例详解
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- 杂记
- Codeforces Round #242 (Div. 2) B. Megacity
- tar命令的C参数
- bootstrap响应式导航
- linux 常用命令及技巧
- 在ASP.NET Atlas中调用Web Service
- 动画杂记
- 昨天面试小结
- ASP.NET中自定义提示对话框
- spring factory-method和factory-bean 使用
- windows eclipse 安装 gradle
- 探索Android内置的ContentProvider(1)
- Objective-C——Message(消息)、Category(分类) 、Protocol(协议) 总结
- 阅读,你是我的眼
- Java关键字final、static使用总结