首页 > 代码库 > ios draw circle with animation
ios draw circle with animation
http://stackoverflow.com/questions/7991086/iphone-core-animation-drawing-a-circle
// Set up the shape of the circleint radius = 100;CAShapeLayer *circle = [CAShapeLayer layer];// Make a circular shapecircle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath;// Center the shape in self.viewcircle.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius, CGRectGetMidY(self.view.frame)-radius);// Configure the apperence of the circlecircle.fillColor = [UIColor clearColor].CGColor;circle.strokeColor = [UIColor blackColor].CGColor;circle.lineWidth = 5;// Add to parent layer[self.view.layer addSublayer:circle];// Configure animationCABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];drawAnimation.duration = 10.0; // "animate over 10 seconds or so.."drawAnimation.repeatCount = 1.0; // Animate only once..// Animate from no part of the stroke being drawn to the entire stroke being drawndrawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];drawAnimation.toValue = [NSNumber numberWithFloat:1.0f];// Experiment with timing to get the appearence to look the way you wantdrawAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];// Add the animation to the circle[circle addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
http://stackoverflow.com/questions/21872610/animate-a-cashapelayer-to-draw-a-progress-circle
[UIBezierPath bezierPathWithArcCenter:arcCenter radius:radius startAngle:M_PI endAngle:-M_PI clockwise:YES];
实现类似qq加载效果
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。