아래 코드를 확인하십시오. 여기에서는 코드를 사용하여 모든 작업을 수행했습니다. 그것이 당신을 도울 수 있기를 바랍니다.
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 <= 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];
좋은 답변입니다. 감사합니다. –