i want to create a navigation bar in which I have a pageControl
as well as the Title in the navigation bar just like the twitter iOS app contains, I got them both by setting the
self.navigationItem.Title = @"Home";
and achieved the PageControl
by creating an instance of UIPageControl
and setting its centre to the centre of the navigation bar and achieving its navigation detection by using the UINavigationController's
Delegate. But the problem is that the pageControl and the title are overlapping each other.. how can I set it like this that the Title should appear on the top of page indicator. Here is the code of the positioning the pageControl
.
self.navigationController.delegate = self;
CGSize navBarSize = self.navigationController.navigationBar.bounds.size;
CGPoint origin = CGPointMake( navBarSize.width/2, navBarSize.height/2 );
self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(origin.x, origin.y,
0, 0)];
[self.pageControl setNumberOfPages:3];
[self.navigationController.navigationBar addSubview:self.pageControl];
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
int index = [self.navigationController.viewControllers indexOfObject:viewController];
self.pageControl.currentPage = index; }