IOS development-UIPageControl for paging image carousel
Paging-related attributes
As long as the pageEnabled attribute of UIScrollView is set to YES, UIScrollView is divided into multiple independent pages, and the content in it can be displayed by page. Generally, the pageEnabled attribute is used with UIPageControl to enhance the paging effect, UIPageControl common attributes include the following: Total number of pages @ property (nonatomic) NSInteger numberOfPages; currently displayed page number @ property (nonatomic) NSInteger currentPage; only one page is displayed, whether to hide the page number indicator @ property (nonatomic) BOOL hidesForSinglePage; color of other page number indicators @ property (nonatomic, retain) UIColor * pageIndicatorTintColor; color of the current page number indicator @ property (nonatomic, retain) UIColor * currentPageIndicatorTintColor;
Paging image carousel instance
# Define ImageCount 5 # import "ViewController. h" @ interface ViewController ()
@ Property (weak, nonatomic) IBOutlet UIScrollView * scrollView; @ property (weak, nonatomic) IBOutlet UIPageControl * pageControl;/*** timer */@ property (nonatomic, strong) NSTimer * timer; @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; // 0. some fixed size parameters CGFloat imageW = self. scrollView. frame. size. width; CGFloat imageH = self. scrollView. frame. size. height; CGFloat imageY = 0; // 1. add imageCount images to scrollView for (int I = 0; I
Storyboard