function: Usually used with Uiscrollview, prompting the user to display the number of pages currently
Common Properties and methods
There are a few pagination "circles"
@property (nonatomic) Nsinteger numberofpages;
Display the current page
@property (nonatomic) Nsinteger currentpage;
If there is only one page, whether it is hidden, the default is Yes
@property (nonatomic) BOOL hidesforsinglepage;
Refresh View
-(void) updatecurrentpagedisplay;
Project:uipagecontroldemo
Open APPDELEGATE.M
In-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions
In the [Self.window makekeyandvisible]; Top Join
Uipagecontrol *pagecontrol = [[Uipagecontrol alloc] initwithframe:cgrectmake (0, 100, 320, 40)];
Pagecontrol.backgroundcolor = [Uicolor Graycolor];
[Self.window Addsubview:pagecontrol];
Run
in Uipagecontrol *pagecontrol = [[Uipagecontrol alloc] initwithframe:cgrectmake (0, 100, 320, 40)]; Add below
Pagecontrol.numberofpages = 10;
Pagecontrol.currentpage = 2;
Run
You can move around by clicking
in pagecontrol.currentpage = 2; Add below
pagecontrol.enabled = NO;
Run
Will pagecontrol.enabled = NO; Comment out Join
[Pagecontrol addtarget:self Action: @selector (change:) forcontrolevents:uicontroleventvaluechanged];
In the Join method
-(void) Change: (Uipagecontrol *) Pagecontrol
{
NSLog (@ "index:%d", pagecontrol.currentpage);
}
Run
Will
Pagecontrol.numberofpages = 10;
Pagecontrol.currentpage = 2;
Switch
Pagecontrol.numberofpages = 1;
Pagecontrol.hidesforsinglepage = yes;//If it's a single page, hide it.
Run
In the real project development time is to customize the control because the small point itself is too small inconvenient operation
Uipagecontrol of iOS controls