UIScrollView
(一般與滾動視圖配合使用)
1.點的個數(shù)? ? ? ? ? ? ? ? ? ? ? ? ? numberOfPages? ? ? ? ? ? ? ? ? ? ? 4
2.選中點的顏色 ? ? ? ? ? ? ? ? ? ?currentPageIndicatorTintColor???????UIColor?orangeColor
3.點的背景顏色 ? ? ? ? ? ? ? ? ?? pageIndicatorTintColor??????????????UIColor?cyanColor
4.點擊方法 ? ? ? ? ? ? ? ? ? ? ? ? ? addTarget: ? ? ? ? ? ? ?action: ? ? ? ? ?forControlEvents: ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?self ? ? ? ? @selector(pageAction:) ? ? ?UIControlEventValueChanged?
5.創(chuàng)建UIPageControl
UIPageControl *page = [[UIPageControl alloc] initWithFrame:CGRectMake(100, 600, 200, 40)];
page.backgroundColor?= [UIColor?redColor];
page.tag = 1000;
[self.view?addSubview:page];
[page?release];
//專門用來縮放的協(xié)議方法
-(UIView?*)viewForZoomingInScrollView:(UIScrollView?*)scrollView{
return?[scrollView.subviews?firstObject];
}
-(void)scrollViewDidEndDecelerating:(UIScrollView?*)scrollView{
//滑動圖片,讓圓點跟著一起動
UIPageControl?*page = (UIPageControl?*)[self.view?viewWithTag:1000];
page.currentPage?=?self.scrollView.contentOffset.x?/?WIDTH;
}
-(void)pageAction:(UIPageControl?*)page{
//點的個數(shù)從第0張開始計算
NSLog(@"%ld",page.currentPage);
//觸發(fā)事件,進行圖片的切換
[self.scrollView?setContentOffset:CGPointMake(WIDTH?* (page.currentPage),?0)?animated:YES];
}