2011-08-01 126 views
0

我有我已經定製了點顏色沒有改變Custome 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)); 
    } 
} 

UIPageControl如果我改變CGContextStrokeEllipseInRect與CGContextFillEllipseInRect那麼它的改變,但我想用CGContextStrokeEllipseInRect

回答

1

你'重新設置填充顏色,但是您想使用筆畫功能。使用CGContextSetStrokeColorWithColor而不是CGContextSetFillColorWithColor