Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Please check the code below. Here, I've done everything using code. Hope it can help you.</p> <pre class="lang-c prettyprint-override"><code>int numberOfPages = 5 ; UIScrollView *scrollQuestionList = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height - 70.0)]; scrollQuestionList.contentSize = CGSizeMake(numberOfPages*scrollQuestionList.frame.size.width, scrollQuestionList.frame.size.height); [self.view addSubview:scrollQuestionList]; scrollQuestionList.backgroundColor = [UIColor clearColor]; scrollQuestionList.delegate = self; scrollQuestionList.showsHorizontalScrollIndicator = NO; scrollQuestionList.pagingEnabled = YES; CGFloat x = 0.0; tagForBtns = 0; for (int i = 1; i &lt;= numberOfPages; i++) { UIView *contentView = [[[UIView alloc] initWithFrame:CGRectMake(x, 0.0, scrollQuestionList.frame.size.width, scrollQuestionList.frame.size.height)] autorelease]; if (i%2 == 0) { [contentView setBackgroundColor:[UIColor grayColor]]; } else { [contentView setBackgroundColor:[UIColor cyanColor]]; } [scrollQuestionList addSubview:contentView]; x+= scrollQuestionList.frame.size.width; } UIPageControl *pageCntrl = [[UIPageControl alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height - 70.0, self.view.frame.size.width, 25.0)]; pageCntrl.numberOfPages = numberOfPages; pageCntrl.backgroundColor = [UIColor clearColor]; [pageCntrl addTarget:self action:@selector(clickedPageControl:) forControlEvents:UIControlEventValueChanged]; pageCntrl.currentPage = 0; [self.view addSubview:pageCntrl]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload