Latest 0.1.0
Homepage https://github.com/Cokile/CCPageControl
License MIT
Platforms ios 8.0, requires ARC
Authors

CCPageControl

A nice, animated UIPageControl alternative. Written in Swift but ported to Objective-C.

CCPageControl

CCPageControl
CCPageControl

Installation

Use Cocoapods

Simply add one line to your Podfile:

pod 'CCPageControl'

Manually

Add all the files in the CCPageControl folder to your project.

Easy to use

Add to user interface

Use Interface Builder

Drag a UIView to your UIViewController and set it’s class to CCPageControl in the Identity inspector. Now you can simply set the public properties in the Attributes inspector.

Remember to add an outlet to your UIViewController for the CCPageControl.

Programmatically

#import "CCPageControl"

// property declaration
@property (nonatomic, strong) CCPageControl *pageControl;

- (void)viewDidLoad {
    // ...
    CGRect frame = //Your frame;
    self.pageControl = [[CCPageControl alloc] initWithFrame:frame];
    self.pageControl.pageIndicatorTintColor = <#UIColor#>; // The default value is UIControl's default tint color.
    self.pageControl.currentPageIndicatorTintColor = <#UIColor#>; // The default value is UIControl's default tint color.
    self.pageControl.numberOfPages = <#NSInteger#>;
    self.pageControl.hidesForSinglePage = YES; // The default value is NO.
    self.pageControl.defersCurrentPageDisplay = YES; // The default value is NO.
}

Note: currentPage starts from 0.

Work with UIScrollView

- (void)viewDidLoad {
    // ...
    self.scrollView.delegate = self;

    [self.pageControl addTarget:self action:@selector(pageControlDidChangeCurrentPage:) forControlEvents:UIControlEventValueChanged];
}

- (void)pageControlDidChangeCurrentPage:(CCPageControl *)pageControl {
    [self.scrollView setContentOffset:CGPointMake(self.scrollView.bounds.size.width * (CGFloat)pageControl.currentPage, 0) animated: true];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSInteger page = scrollView.contentOffset.x / scrollView.bounds.size.width;
    [self.pageControl setCurrentPage:page];
}

Acknowledgement

Thanks to original developer Kasper Lahti.

https://github.com/kasper-lahti/PageControl

Latest podspec

{
    "name": "CCPageControl",
    "platforms": {
        "ios": "8.0"
    },
    "version": "0.1.0",
    "license": {
        "type": "MIT"
    },
    "homepage": "https://github.com/Cokile/CCPageControl",
    "authors": {
        "Cokile": "[email protected]"
    },
    "summary": "u25cf u25cb u25cb u25cb A nice, animated UIPageControl alternative. Written in Swift, port to Objective-C.",
    "source": {
        "git": "https://github.com/Cokile/CCPageControl.git",
        "tag": "v0.1.0"
    },
    "source_files": "CCPageControl/*",
    "requires_arc": true
}

Pin It on Pinterest

Share This