我想做这样的事情:
我试图用这样的核心图形来制作它:
float radius = CGRectGetWidth(rect)/2.0f - self.circleBorderWidth/2.0f;
float angleOffset = 0;
UIBezierPath *aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect))
radius:radius
startAngle:-angleOffset
endAngle:(mCircleSegs + 1)/(float)kCircleSegs*M_PI*2 - angleOffset
clockwise:YES];
CGPathRef shape = CGPathCreateCopyByStrokingPath(aPath.CGPath, NULL, 3, kCGLineCapSquare, kCGLineJoinMiter, 1.0f);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextAddPath(ctx, shape);
CGContextClip(ctx);
AngleGradientLayer *angle = [[AngleGradientLayer alloc] init];
angle.colors = [NSArray arrayWithObjects:
(id)[UIColor colorWithRed:0 green:0 blue:0 alpha:1].CGColor,
(id)[UIColor colorWithRed:1 green:1 blue:1 alpha:1].CGColor,
nil];
CGContextClipToRect(ctx, self.bounds);
[angle drawInContext:ctx];
[angle release];
但我认为我在这里走错了路。它看起来不像示例。CoreGraphics 能画出这样的东西吗?如何?