This article just records a custom UIPageControl Making , It's very simple   The source code will be linked at the bottom , I hope to have more exchanges , Support a lot .

First of all, the effect picture is as follows :

First, make one UISCrollView

// It is recommended to do so , Memory leakage can be avoided

UIScrollView *scrol = [[UIScrollViewalloc]init];

self.scrol = scrol;

[scrol release];

MyPageControl *page = [[MyPageControlalloc]init];

self.pageControl = page;

[page release];

//   Set up UIScrollView Some properties of

self.scrol.frame =CGRectMake(0,5,320,150);

self.scrol.contentSize =CGSizeMake(320*3,150);

self.scrol.showsHorizontalScrollIndicator =NO;

self.scrol.pagingEnabled =YES;

self.scrol.bounces =NO;

self.scrol.delegate =self;

//     Add here 3 A picture For demonstration

for (int i = 0; i<3; i++) {

UIImageView *imgv = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"default_pic.png"]];

imgv.frame = CGRectMake(i*320,0,320, 150);

[self.scroladdSubview:imgv];

[imgv release];

}

[self.viewaddSubview:self.scrol];

//   Add shadow below picture

UIImageView *img_shade = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"shade.png"]];

img_shade.frame = CGRectMake(0,135,320, 20);

//   Here's the point

CGRect rect =CGRectMake(img_shade.center.x-self.pageControl.frame.size.width/2, img_shade.frame.size.height -20,35,20);

self.pageControl.frame = rect;  //     Set coordinates

[_pageControlsetCurrentPage:0];//     Set current display

[_pageControlsetNumberOfPages:3];//     How many sets are there

self.pageControl.backgroundColor = [UIColorclearColor];//     Set the background color to none

[selfsetPageControlPoint];//     Here is a method to set the color of the picture , That's because it's in the middle of nowhere UIScrollView You can change the color when you slide

[self.pageControlsetHidesForSinglePage:YES];//     This property is a description , When there is only one picture, a dot should also be displayed , The default is NO, That is, a point is not displayed

[img_shade addSubview:self.pageControl];

[self.view addSubview:img_shade];

[img_shade release];

Source code address :http://download.csdn.net/detail/zgcrichard/6224757

UIPageControl One of the Demo More articles about

  1. angular Developers make complaints about react+redux The complexity of :“ One demo Prove that your development is inefficient ”

    I once saw an article , Is written jquery Developers make complaints about angular The complexity of . As a angular developer , I'll make complaints about it. react+redux The complexity of . Example In order to make everyone comfortable , I use the simplest one demo To show r ...

  2. First time to know nginx First of all demo

    The mall project has been in operation for more than a month , Think of having to use load balancing , Have a brief understanding of nginx, First share the first demo, After going online in May , Will continue to share a range of relevant knowledge . stay nginx The root directory , Used a batch file of Yuanyou nginx.ba ...

  3. springMvc One of the first demo

    1. download jar package http://repo.spring.io/libs-release-local/org/springframework/spring/4.2.3.RELEASE/ 2. Download the source code j ...

  4. Android Notice bar Notification Integration of Study in an all-round way ( One DEMO Let you fully understand it )

    stay android In the application layer of , It involves a lot of application frameworks , for example :Service frame ,Activity Management mechanism ,Broadcast Mechanism , Dialog frame , Title block frame , The status bar frame , A notification mechanism ,ActionBar Frame, etc . ...

  5. How to be in WTL and MFC Use in duilib And how to use it statically duilib library !( Elementary explanation With a Demo)

    About duilib The history of , I won't say more , People who can read this article have a certain understanding to find this . Let me just talk about the basic use of this library . I'm personally interested in some good technologies . For personal reasons Like to touch a good technology . the ...

  6. White box test gtest first demo

    know gtest After the tool , About its use , We will use a demo Show me the program gtest How to use and display the results . One . What needs to be tested C++ Code : #include "myfunction.h" // ...

  7. stay VS To realize webService One of the demo( The illustration )

    stay VS To realize webService One of the demo( The illustration ) So let's create one web project , Create good web After the project , Add new item ——web service In the new good web The following code is written in the service file : Build current solution . Create a new one winf ...

  8. Cocos2d-x Study (1)—— adopt Cocos Studio Create the first one Demo

    There has been a big change in my work recently , The self-study mood is also rising slowly , I've been studying it unity Technology . Because I changed my job, I would start to contact cocos2d-x. But it doesn't mean to stop the research unity, It will continue when there is time . The company's cocos2 ...

  9. Use android Of mediaplayer Make it One demo, Welcome to test

    The attachment is a simple one for a customized video product demo, To illustrate android Of mediaplayer How it is used . http://files.cnblogs.com/guobaPlayer/palyerD ...

Random recommendation

  1. Learn from scratch Python Week 7 : Object-oriented progression ( Need to be revised )

    One , Attributes of a class (1) Example Get the number of created objects through attributes class Plane: pCount = 0 # Class properties def __init__(self,name,category): self.nam ...

  2. stay ThoughtWorks What have I learned in the past few years ?

    Before you know it , from 2012 year 5 month 1 Join in ThoughtWorks Up to now , already 3 In more than . Time passed quickly , I have done a lot of things in the past three years , But when you think about it, there's nothing particularly worth mentioning . After staying in a company for a long time, I always take many things for granted , ...

  3. Preliminary discussion Linux ----------&gt; Build your own Vim IDE

    One .   Opening Preface ( The picture shows the words crossing the line , Please refresh ) packed Ubuntu15.04 After the system , Have fun Ubuntu, I think it's still very good . Than windows fast , As soon as you boot, you can open the program you want , But in windows Next you ...

  4. [BZOJ1786][BZOJ1831] Reverse alignment

    [BZOJ1786][BZOJ1831] Reverse alignment Test description Input Output Input example - - Output example Data scale and agreement see “ Input ” Answer key First of all, this problem has a property , namely , The number you fill in will not drop from left to right . Prove it to the reader himself yy ...

  5. #ifdef __cplusplus extern &quot;C&quot; { #endif // A piece of code #ifdef __cplusplus } #endif

    What does this code mean ? First ,__cplusplus yes cpp Custom macro in , So the definition of this macro means that this is a cpp Code for , in other words , What does the above code mean : If this is a paragraph cpp Code for , Then join in " ...

  6. By myself 6 year .net Proven work experience .net It's true that the salary is higher than the salary Java low

    I haven't visited blog Garden for a long time , I haven't make complaints about it for a long time. . What's the matter? ? Life is stressful , Make complaints about finding places. . The typesetting is not very good , The writing is not very good , You can see that I'm not a hired writer . Work till this summer , There has been a 6 A year , It's used all the time .net technology , But recently, I have been working hard ...

  7. KeybMap Keyboard mapping tool update to V1.5( The revision )

    KeybMap  Update to V1.5, It mainly adds the function of modifying the definition of some multimedia keys , You can also define any key to open the specified program . 3 month 9 Japan slightly revised . http://www.mympc.org/down/1/2005- ...

  8. Saving custom fields in production order

    In additional data screen 1.PPCO0012->EXIT_SAPLCOKO1_001->ZXCO1U11 ​ ​ ci_aufk-zxxx = i_caufvd ...

  9. It's your choice PRINCE2 still PMP authentication

    It's your choice PRINCE2 still PMP authentication ? A lot of people ask me , This is a very common problem , As a project manager , Should they choose PRINCE2 or PMP authentication , Because these two certifications are very popular all over the world . PRINCE2 It's one ...

  10. java adopt IO Stream copy file

    package kimoji; import java.io.*; public class FileTest { public static void main(String[] args) thr ...