Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3310330
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:44:50+00:00 2026-05-17T21:44:50+00:00

I am developing an application in which I want to change either color or

  • 0

I am developing an application in which I want to change either color or image of UIPageControl pagination dots. How can I change it? Is it possible to customize UIpageControl on above scenario?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:44:51+00:00Added an answer on May 17, 2026 at 9:44 pm

    UPDATE:

    This answer is 6 years old and very outdated, but it’s still attracting votes and comments. Ever since iOS 6.0 you should be using the pageIndicatorTintColor and currentPageIndicatorTintColor properties on UIPageControl.

    ORIGINAL ANSWER:

    I ran into this problem today and decided to write my own simple replacement class.

    It’s a sublassed UIView that uses Core Graphics to render the dots in the colors you specify.

    You use the exposed properties to customize and control it.

    If you want to you can register a delegate object to get notifications when the user taps on one of the little page dots. If no delegate is registered then the view will not react to touch input.

    It’s completely fresh from the oven, but seems to work. Let me know if you run into any problems with it.

    Future improvements:

    • Resize the dots to fit the current
      bounds if there are too many.
    • Don’t redraw the entire view in drawRect:

    Example use:

    CGRect f = CGRectMake(0, 0, 320, 20); 
    PageControl *pageControl = [[[PageControl alloc] initWithFrame:f] autorelease];
    pageControl.numberOfPages = 10;
    pageControl.currentPage = 5;
    pageControl.delegate = self;
    [self addSubview:pageControl];
    

    Header file:

    //
    //  PageControl.h
    //
    //  Replacement for UIPageControl because that one only supports white dots.
    //
    //  Created by Morten Heiberg <morten@heiberg.net> on November 1, 2010.
    //
    
    #import <UIKit/UIKit.h>
    
    @protocol PageControlDelegate;
    
    @interface PageControl : UIView 
    {
    @private
        NSInteger _currentPage;
        NSInteger _numberOfPages;
        UIColor *dotColorCurrentPage;
        UIColor *dotColorOtherPage;
        NSObject<PageControlDelegate> *delegate;
        //If ARC use __unsafe_unretained id delegate;
    }
    
    // Set these to control the PageControl.
    @property (nonatomic) NSInteger currentPage;
    @property (nonatomic) NSInteger numberOfPages;
    
    // Customize these as well as the backgroundColor property.
    @property (nonatomic, retain) UIColor *dotColorCurrentPage;
    @property (nonatomic, retain) UIColor *dotColorOtherPage;
    
    // Optional delegate for callbacks when user taps a page dot.
    @property (nonatomic, retain) NSObject<PageControlDelegate> *delegate;
    
    @end
    
    @protocol PageControlDelegate<NSObject>
    @optional
    - (void)pageControlPageDidChange:(PageControl *)pageControl;
    @end
    

    Implementation file:

    //
    //  PageControl.m
    //
    //  Replacement for UIPageControl because that one only supports white dots.
    //
    //  Created by Morten Heiberg <morten@heiberg.net> on November 1, 2010.
    //
    
    #import "PageControl.h"
    
    // Tweak these or make them dynamic.
    #define kDotDiameter 7.0
    #define kDotSpacer 7.0
    
    @implementation PageControl
    
    @synthesize dotColorCurrentPage;
    @synthesize dotColorOtherPage;
    @synthesize delegate;
    
    - (NSInteger)currentPage
    {
        return _currentPage;
    }
    
    - (void)setCurrentPage:(NSInteger)page
    {
        _currentPage = MIN(MAX(0, page), _numberOfPages-1);
        [self setNeedsDisplay];
    }
    
    - (NSInteger)numberOfPages
    {
        return _numberOfPages;
    }
    
    - (void)setNumberOfPages:(NSInteger)pages
    {
        _numberOfPages = MAX(0, pages);
        _currentPage = MIN(MAX(0, _currentPage), _numberOfPages-1);
        [self setNeedsDisplay];
    }
    
        - (id)initWithFrame:(CGRect)frame
    {
        if ((self = [super initWithFrame:frame]))
        {
            // Default colors.
            self.backgroundColor = [UIColor clearColor];
            self.dotColorCurrentPage = [UIColor blackColor];
            self.dotColorOtherPage = [UIColor lightGrayColor];
    
            UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedRight:)];
            [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
            [self addGestureRecognizer:swipeRight];
    
    
    
    
            UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipedLeft:)];
            [swipe setDirection:UISwipeGestureRecognizerDirectionLeft];
            [self addGestureRecognizer:swipe];
    
        }
        return self;
    }
    -(void) swipedLeft:(UISwipeGestureRecognizer *) recognizer
    {
        self.currentPage++;
    }
    -(void) swipedRight:(UISwipeGestureRecognizer *) recognizer
    {
        self.currentPage--;
    }
    
    - (void)drawRect:(CGRect)rect 
    {
        CGContextRef context = UIGraphicsGetCurrentContext();   
        CGContextSetAllowsAntialiasing(context, true);
    
        CGRect currentBounds = self.bounds;
        CGFloat dotsWidth = self.numberOfPages*kDotDiameter + MAX(0, self.numberOfPages-1)*kDotSpacer;
        CGFloat x = CGRectGetMidX(currentBounds)-dotsWidth/2;
        CGFloat y = CGRectGetMidY(currentBounds)-kDotDiameter/2;
        for (int i=0; i<_numberOfPages; i++)
        {
            CGRect circleRect = CGRectMake(x, y, kDotDiameter, kDotDiameter);
            if (i == _currentPage)
            {
                CGContextSetFillColorWithColor(context, self.dotColorCurrentPage.CGColor);
            }
            else
            {
                CGContextSetFillColorWithColor(context, self.dotColorOtherPage.CGColor);
            }
            CGContextFillEllipseInRect(context, circleRect);
            x += kDotDiameter + kDotSpacer;
        }
    }
    
    - (void)dealloc 
    {
        [dotColorCurrentPage release];
        [dotColorOtherPage release];
        [delegate release];
        [super dealloc];
    }
    
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        if (!self.delegate) return;
    
        CGPoint touchPoint = [[[event touchesForView:self] anyObject] locationInView:self];
    
        CGFloat dotSpanX = self.numberOfPages*(kDotDiameter + kDotSpacer);
        CGFloat dotSpanY = kDotDiameter + kDotSpacer;
    
        CGRect currentBounds = self.bounds;
        CGFloat x = touchPoint.x + dotSpanX/2 - CGRectGetMidX(currentBounds);
        CGFloat y = touchPoint.y + dotSpanY/2 - CGRectGetMidY(currentBounds);
    
        if ((x<0) || (x>dotSpanX) || (y<0) || (y>dotSpanY)) return;
    
        self.currentPage = floor(x/(kDotDiameter+kDotSpacer));
        if ([self.delegate respondsToSelector:@selector(pageControlPageDidChange:)])
        {
            [self.delegate pageControlPageDidChange:self];
        }
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an application which currently have hundreds of objects created. Is it possible
I am developing an application which will be connected to Access database at the
I'm developing an application which has a lot of text and also different modules
I am developing a web application which has Chart Controls. I have developed a
I am developing a small application which lists the contents from files of a
We are developing a web application which is available in 3 languages. There are
I am developing an .net application which heavely depends on plugins. The application itself
I am developing a Cocoa application which communicates constantly with a web service to
When developing a new web based application which version of html should you aim
I'm developing non-interactive cpu-bound application which does only computations, almost no IO. Currently it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.