我有UIPageControl我自定义它的点颜色没有改变
- (void)drawRect:(CGRect)rect {
if (hidesForSinglePage == NO || [self numberOfPages] > 1){
if (activePageColor == nil){
activePageColor = [UIColor blackColor];
}
if (inactivePageColor == nil){
inactivePageColor = [UIColor grayColor];
}
CGContextRef context = UIGraphicsGetCurrentContext();
// float dotSize = self.frame.size.height / 6;
float dotSize = self.frame.size.height / 2;
float dotsWidth = (dotSize * [self numberOfPages]) + (([self numberOfPages] - 1) 10);
float offset = (self.frame.size.width - dotsWidth) / 2;
for (NSInteger i = 0; i < [self numberOfPages]; i++){
if (i == [self currentPage]){
CGContextSetFillColorWithColor(context, [activePageColor CGColor]);
} else {
CGContextSetFillColorWithColor(context, [inactivePageColor CGColor]);
}
CGContextStrokeEllipseInRect(context, CGRectMake(offset + (dotSize + 10) * i,(self.frame.size.height / 2) - (dotSize / 2), dotSize, dotSize));
}
}
如果我用CGContextFillEllipseInRect更改CGContextStrokeEllipseInRect然后它会改变但我想使用CGContextStrokeEllipseInRect
答案 0 :(得分:1)
您正在设置填充颜色,但您想使用描边功能。使用CGContextSetStrokeColorWithColor
代替CGContextSetFillColorWithColor
。