Pagination control is a visible indicator to replace the navigation bar, easy to direct the page, the most typical application is the iphone's main screen, when the number of icons will automatically increase the page, at the bottom of the screen you will see the origin, used just the current page, and will automatically update with the page.
First, create
Copy Code code as follows:
uipagecontrol* Mypagecontrol = [[Uipagecontrol alloc]initwithframe:cgrectmake (0.0, 400.0, 320.0, 0.0)];
Second, set properties
Number of pages
Copy Code code as follows:
Mypagecontrol.numberofpages = 5;
The default first page is selected. If you want to select a different page, you can set the CurrentPage property. The page index starts at 0:
Copy Code code as follows:
Mypagecontrol.currentpage =3;//Current pages, fourth page
By default, even if there is only one page, the indicator is displayed. If you want to hide the indicator with only one page, you can set the value of Hideforsinglepage to YES.
Copy Code code as follows:
Mypagecontrol.hidesforsinglepage=yes;
You can set Deferscurrentpagedisplay to Yes if you want to update the current indicator page only after you have had time to perform your operation. In this case you must call the control's updatecurentpagedisplay to update the current page:
Copy Code code as follows:
Mypagecontrol.deferscurrentpagedisplay = YES;
[Mypagecontrol Updatecurrentpagedisplay];
Third, display control
Copy Code code as follows:
[Self.view Addsubview:mypagecontrol];
IV. notification
A uicontroleventvakuechanged event occurs when a user points to a paging control. You can specify an action for the Uicontrol class by using the Addtarget method:
Copy Code code as follows:
-(void) pagechanged: (ID) sender{
uipagecontrol* control = (uipagecontrol*) sender;
Nsinteger page = control.currentpage;
Add the code you want to process
}
[Mypagecontrol addtarget:self Action: @selector (pagechanged:) forcontrolevents:uicontroleventvaluechanged];
List of common properties
Copy Code code as follows:
Create Uipagecontrol
Uipagecontrol * page = [[Uipagecontrol alloc] Initwithframe:cgrectmake (0, SELF.VIEW.BOUNDS.SIZE.HEIGHT-50, Self.view.bounds.size.width, 50)];
Set Background color
Page.backgroundcolor = [Uicolor Clearcolor];
Set the number of small circles
Page.numberofpages = 15;
Set the color of a small circle
Page.pageindicatortintcolor = [Uicolor Orangecolor];
Set the color of the current page's small circle
Page.currentpageindicatortintcolor = [Uicolor Redcolor];
Get/Change Current page
Page.currentpage = 1;
Add Click events
[Page addtarget:self action: @selector (Pageclick:) forcontrolevents:uicontroleventvaluechanged];