0

I have UIPageControl which I have made custom its dot color is not changing

- (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));
    }
}

if I change CGContextStrokeEllipseInRect with CGContextFillEllipseInRect then its changing but I want to use CGContextStrokeEllipseInRect

1 Answer 1

1

You're setting the fill color, but you want to use a stroke function. Use CGContextSetStrokeColorWithColor instead of CGContextSetFillColorWithColor.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.