Search code examples
iosiphoneuipagecontrol

Dots of UIPageControl


I am using UIPageControl with UIScrollView.

My issue is that the dots of the UIPageControl are also drawing out of the frame of the UIPageControl. I am using the following code:

m_pUIPageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(30,410,260,20)];
[m_pUIPageControl setBackgroundColor:[UIColor blackColor]];
[m_pUIPageControl setPageIndicatorTintColor:[UIColor whiteColor]];
m_pUIPageControl.numberOfPages = 40;
m_pUIPageControl.currentPage = 0;
[m_pUIPageControl setCurrentPageIndicatorTintColor:[UIColor redColor]];
[m_pUIPageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:m_pUIPageControl];

How i can control the dots ?


Solution

  • Make the frame bigger so that the control is the correct size for the number of page dots.

    You can also look at applying a scale transform to the control but be careful not to make the control unusable / ineffective.