Skip to content

Latest commit

 

History

History
101 lines (73 loc) · 2.97 KB

README.md

File metadata and controls

101 lines (73 loc) · 2.97 KB

About TAPageControl

TAPageControl basically is a more powerfull UIPageControl. It offers you greater flexibility and customization.

demo

How it works

It works like a basic UIPageControl but with more options and properties so it can fit your needs. It comes with a default dot view, but you can easily replace it by any UIView object that you want (more on that later) or with any image.

The only required property to set to get it working, like UIPageControl, is a number of pages :

self.pageControl.numberOfPages = 9;

Installation

CocoaPods

With CocoaPods by adding in your podfile the following line :

pod 'TAPageControl'

Manually

It's quite easy, just download the archive and add the TAPageControl folder to your own project. Don't forget to import the header file wherever you need it :

#import "TAPageControl.h"

Customization's magic

If you are looking for a page control I guess it's because the default one provided by Apple did not answer your need. Then you are looking for a page control that you can customize at will and you are at the right place!

TAPageControl uses two kind of source to display "dots" representing pages :

  • UIImage
  • UIView

UIImage is the simplest way to make your page control look the way you want. There are two properties :

/**
 *  UIImage to represent a dot.
 */
@property (nonatomic) UIImage *dotImage;

/**
 *  UIImage to represent current page dot.
 */
@property (nonatomic) UIImage *currentDotImage;

By setting both properties with your images, the control will take care of displaying the correct version depending on the current page.

But what if you need more control? Well, will a UIView be enough for you? By using :

/**
 *  The Class of your custom UIView, make sure to respect the TAAbstractDotView class.
 */
@property (nonatomic) Class dotViewClass;

The control will instantiate your UIView class as a dot. I recommend subclassing your view with TAAbstractDotView because the only important thing to respect is the method to switch your view between active/inactive state.

@interface TAAbstractDotView : UIView

/**
 *  A method call let view know which state appearance it should take. Active meaning it's current page. Inactive not the current page.
 *
 *  @param active BOOL to tell if view is active or not
 */
- (void)changeActivityState:(BOOL)active;

There you go, you can do whatever you want with it. Shape, color, animations... everything.

Take a look at the sample project to see how great and simple it is by yourself ;)

License

TAPageControl is available under the MIT license. See the LICENSE file for more info.

More

Contribute to this repository as much as you like, and any advice are welcome! =). I hope you will enjoy it.