我想绘制以下UIPageControl
指标:
我目前有以下代码,其结果是:
if (isHighlighted) {
UIBezierPath *ovalPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 6, 6)];
[[UIColor blackColor] setStroke];
[ovalPath stroke];
[ovalPath addClip];
UIColor *lightGradientColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1.0];
UIColor *darkGradientColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1.0];
CGFloat locations[2] = {0.0 ,1.0};
CFArrayRef colors = (__bridge CFArrayRef) [NSArray arrayWithObjects:(id)lightGradientColor.CGColor,
(id)darkGradientColor.CGColor,
nil];
CGColorSpaceRef colorSpc = CGColorSpaceCreateDeviceRGB();
CGGradientRef gradient = CGGradientCreateWithColors(colorSpc, colors, locations);
CGContextDrawLinearGradient(context, gradient, CGPointMake(CGRectGetMaxX([ovalPath bounds]), 0), CGPointMake(0, CGRectGetMaxY([ovalPath bounds])), (CGGradientDrawingOptions)NULL);
CGColorSpaceRelease(colorSpc);
CGGradientRelease(gradient);
} else {
UIBezierPath *ovalPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 6, 6)];
[[UIColor colorWithWhite:1 alpha:0.3] setFill];
[[UIColor whiteColor] setFill];
[ovalPath fill];
}
但我无法让它看起来像图片中的指示器。我将如何设法获得正确的结果?