UIPageControl - How to make the background transparent?

sselvan picture sselvan · Jan 8, 2014 · Viewed 18k times · Source

I am using UIPageControl and trying to make the background transparent.

UIPageControl *pageControl = [UIPageControl appearance];
pageControl.pageIndicatorTintColor = [UIColor lightGrayColor];
pageControl.currentPageIndicatorTintColor = [UIColor blackColor];
pageControl.backgroundColor = [UIColor blackColor];

Any suggestions?

Tried

pageControl.backgroundColor = [UIColor clearColor];

no luck.

============

Okay, as mentioned by @powerj1984 and @daniellarsson UIPageControl seems to be not alterable with respect to position and background color.

So I decided to move this to UIViewController and created a UIPageControl and

@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;

And then bring this to top of my UIPageViewController as in viewDidLoad

self.pageControl.numberOfPages = self.pageTitles.count;    
[self.view addSubview:_pageControl.viewForBaselineLayout]; 

Then I updated the index of UIPageControl in viewControllerBeforeViewController and viewControllerAfterViewController

NSUInteger index = ((HomePageContentViewController*) viewController).pageIndex; 
self.pageControl.currentPage = index;

Answer

sselvan picture sselvan · Jan 10, 2014

Okay, as mentioned by @powerj1984 and @daniellarsson UIPageControl seems to be not alterable with respect to position and background color.

So I decided to move this to UIViewController and created a UIPageControl and

@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;

And then bring this to top of my UIPageViewController as in viewDidLoad

self.pageControl.numberOfPages = self.pageTitles.count;    
[self.view addSubview:_pageControl.viewForBaselineLayout]; 

Then I updated the index of UIPageControl in viewControllerBeforeViewController and viewControllerAfterViewController

NSUInteger index = ((HomePageContentViewController*) viewController).pageIndex; 
self.pageControl.currentPage = index;