- (void)drawError
{
[_logoView removeFromSuperview];
_logoView = [[UIView alloc] initWithFrame:CGRectMake(([self getSelfSize].width-Simble_SIZE)/2, Simble_TOP, Simble_SIZE, Simble_SIZE)];
// 绘制轨迹 with UIBezierPath
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(Simble_SIZE/2, Simble_SIZE/2) radius:Simble_SIZE/2 startAngle:0 endAngle:M_PI*2 clockwise:YES];
CGPoint p1 = CGPointMake(Simble_SIZE/4, Simble_SIZE/4);
[path moveToPoint:p1];
CGPoint p2 = CGPointMake(Simble_SIZE/4*3, Simble_SIZE/4*3);
[path addLineToPoint:p2];
CGPoint p3 = CGPointMake(Simble_SIZE/4*3, Simble_SIZE/4);
[path moveToPoint:p3];
CGPoint p4 = CGPointMake(Simble_SIZE/4, Simble_SIZE/4*3);
[path addLineToPoint:p4];
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
layer.lineWidth = 5;
layer.path = path.CGPath;
layer.fillColor = [UIColor clearColor].CGColor;
layer.strokeColor = [UIColor redColor].CGColor;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:NSStringFromSelector(@selector(strokeEnd))];
animation.fromValue = @0;
animation.toValue = @1;
animation.duration = 0.5;
[layer addAnimation:animation forKey:NSStringFromSelector(@selector(strokeEnd))];
[_logoView.layer addSublayer:layer];
[self addSubview:_logoView];
}
网友评论