A summary of Uipagecontrol paging controls used in IOS app development _ios

Source: Internet
Author: User
Tags set background

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];

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.