Latest2.0.9
Homepagehttps://github.com/stefanceriu/SCPageViewController
LicenseMIT License
Platformsios 5.0, requires ARC
DependenciesSCScrollView
FrameworksUIKit, QuartzCore, CoreGraphics, Foundation
Authors

SCPageViewController is a container view controller similar to UIPageViewController but which provides more control, is much more customizable and, arguably, has a better overall design.
It supports the following features:

  • Customizable transitions and animations (through layouters and custom easing functions)
  • Incremental updates with user defined animations
  • Bouncing and realistic physics
  • Correct appearance calls, even while interactions are in progres
  • Custom layouts and animated layout changes
  • Vertical and horizontal layouts
  • Pagination
  • Content insets
  • Completion blocks
  • Customizable interaction area and number of touches required

and more..

Screenshots

SCPageViewController

Implementation details

SCPageViewController is build on top of an UIScrollView subclass (SCScrollView) which provides it with correct physics, callbacks for building the pagination, navigational constraints and custom transitions. It also can work with user defined interaction areas and minimum/maximum number of touches. It’s worth noting that SCScrollView also powers SCStackViewController

SCPageViewController relies on page layouters to know where to place each of the controllers at every point. Page layouters are built on top of a simple protocol with methods for providing the final and intermediate view controller frames, and custom animations for page insertions, deletions, moves and reloads. The demo project contains 4 examples: plain with inter-item spacings, parallax, sliding and cards.

Usage

  • Create a new instance and set its data source and delegate
    self.pageViewController = [[SCPageViewController alloc] init];
    [self.pageViewController setDataSource:self];
    [self.pageViewController setDelegate:self];
  • SCPageViewController relies on layouters that define how pages are layed out. You can use one of the included ones or create a custom class that implements the SCPageLayouterProtocol.
    [self.pageViewController setLayouter:[[SCPageLayouter alloc] init] animated:NO completion:nil];
  • Implement the SCPageViewControllerDataSource which defines the total number of pages and the view controllers to be used for each of them.
- (NSUInteger)numberOfPagesInPageViewController:(SCPageViewController *)pageViewController;

- (UIViewController *)pageViewController:(SCPageViewController *)pageViewController viewControllerForPageAtIndex:(NSUInteger)pageIndex;
  • Optionally, modify the following properties to your liking
    // Enable/disable pagination
    [self.pageViewController setPagingEnabled:NO];

    // Ignore navigation contraints (bounce between pages)
    [self.pageViewController setContinuousNavigationEnabled:YES];

    // Have the page view controller come to a rest slower
    [self.pageViewController setDecelerationRate:UIScrollViewDecelerationRateNormal];

    // Disable bouncing
    [self.pageViewController setBounces:NO];

    // Customize how many number of touches are required to interact with the pages
    [self.pageViewController.scrollView.panGestureRecognizer setMinimumNumberOfTouches:2];
    [self.pageViewController.scrollView setMaximumNumberOfTouches:1];

    // Allow interaction only in the specified area
    //SCScrollViewTouchApprovalArea *touchApprovalArea = [[SCScrollViewTouchApprovalArea alloc] init];
    //[touchApprovalArea setPath:[UIBezierPath bezierPathWithRect:someFrame]];
    //[self.pageViewController.scrollView addTouchApprovalArea:touchApprovalArea];

    //Use different easing functions for animations and navigation
    [self.pageViewController setEasingFunction:[SCEasingFunction easingFunctionWithType:SCEasingFunctionTypeLinear]];

    // Change the default animation durations
    [self.pageViewController setAnimationDuration:1.0f];
Incremental updates

SCPageViewController also supports incremental updates and all the animations are customizable through the layouter.

    [self.pageViewController insertPagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated completion:^(void)completion];

    [self.pageViewController deletePagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated completion:^(void)completion]

    [self.pageViewController reloadPagesAtIndexes:(NSIndexSet *)indexes animated:(BOOL)animated completion:^(void)completion]

    [self.pageViewController movePageAtIndex:(NSUInteger)fromIndex toIndex:(NSUInteger)toIndex animated:(BOOL)animated completion:^(void)completion]
Easing functions

SCPageViewController can work with custom easing functions defined through the SCEasingFunctionProtocol. It comes bundled with 31 different ones (thanks to AHEasing) and new ones can be created with ease.

  • Ease In Out Back
    Plain+BackEaseInOut

  • Ease Out Bounce
    Plain+BounceEaseOut

  • Ease Out Elastic
    Plain+ElasticEaseOut
For more usage examples please have a look at the included demo project (or pod try SCPageViewController)

License

SCPageViewController is released under the MIT License (MIT) (see the LICENSE file)

Contact

Any suggestions or improvements are more than welcome and I would also love to know if you are using this component in a published application.
Feel free to contact me at [email protected] or @stefanceriu.

Latest podspec

{
    "name": "SCPageViewController",
    "version": "2.0.9",
    "platforms": {
        "ios": "5.0"
    },
    "summary": "SCPageViewController is a container view controller similar to UIPageViewController which provies more control and is much more customizable",
    "description": "SCPageViewController is a container view controller similar to UIPageViewController but which provies more control, is much more customizable and, arguably, has a better overall design. nIt supports the following features:nn- Customizable transitions and animations (through layouters and custom easing functions)n- Incremental updates with user defined animationsn- Bouncing and realistic physicsn- Correct appearance calls, even while interactions are in progresn- Custom layouts and animated layout changesn- Vertical and horizontal layoutsn- Paginationn- Content insetsn- Completion blocksn- Customizable interaction area and number of touches requirednnand more..",
    "homepage": "https://github.com/stefanceriu/SCPageViewController",
    "authors": {
        "Stefan Ceriu": "[email protected]"
    },
    "social_media_url": "https://twitter.com/stefanceriu",
    "source": {
        "git": "https://github.com/stefanceriu/SCPageViewController.git",
        "tag": "v2.0.9"
    },
    "license": {
        "type": "MIT License",
        "file": "LICENSE"
    },
    "source_files": [
        "SCPageViewController/*",
        "SCPageViewController/Layouters/*"
    ],
    "requires_arc": true,
    "frameworks": [
        "UIKit",
        "QuartzCore",
        "CoreGraphics",
        "Foundation"
    ],
    "dependencies": {
        "SCScrollView": [
            "~> 1.1"
        ]
    }
}

Pin It on Pinterest

Share This