• Stars
    star
    353
  • Rank 120,322 (Top 3 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Just like UIPageViewController but better.. :)

SCPageViewController

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

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 to define the total number of pages, the view controllers to be used for each of them and which one show be displayed first.
- (NSUInteger)numberOfPagesInPageViewController:(SCPageViewController *)pageViewController;

- (UIViewController *)pageViewController:(SCPageViewController *)pageViewController viewControllerForPageAtIndex:(NSUInteger)pageIndex;

- (NSUInteger)initialPageInPageViewController:(SCPageViewController *)pageViewController;
  • 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.scrollView setDecelerationRate:UIScrollViewDecelerationRateNormal];

    // Disable bouncing
    [self.pageViewController.scrollView 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.

More Repositories

1

SCSiriWaveformView

UIView subclass that reproduces the waveform effect seen in Siri on iOS 7.
Objective-C
1,090
star
2

SCXcodeMiniMap

Sublime Text like Minimap for Xcode
Objective-C
1,026
star
3

SCXcodeSwitchExpander

Xcode plugin that enables switch cases autocompletion
Objective-C
655
star
4

SCStringsUtility

OS X / iOS Translations helper
Objective-C
526
star
5

SCSafariPageController

A page view controller component that reproduces Mobile Safari's tab switching behavior
Objective-C
388
star
6

SCStackViewController

SCStackViewController is a container view controller which allows you to stack other view controllers on the top/left/bottom/right of the root and build custom transitions between them while providing correct physics and appearance calls.
Objective-C
265
star
7

SCSkypeActivityIndicatorView

Activity indicator view similar to the one seen in the Skype apps.
Objective-C
106
star
8

SCXcodeEditorInset

Xcode plugin that adds an empty (configurable) space to the end of the editor text view
Objective-C
63
star
9

SCNavigationController

SCNavigationController is an UINavigationController like container view controller and was built to provide and expose more features and control
Objective-C
46
star
10

SCXcodeTabSwitcher

Enables changing Xcode tabs using the ⌘cmd + [1..9] keys
Objective-C
42
star
11

SCScrollView

UIScrollView subclass that can use a custom easing function to animate the setting of the content offset
Objective-C
20
star
12

Xcode-Headers

Xcode headers dump
Objective-C
18
star
13

UIScrollView-ScrollerAdditions

Customising UIScrollView's scroll bars
Objective-C
17
star
14

SCDragController

SCDragController is a component meant to aid the development of drag & drop behaviors.
Objective-C
10
star
15

SCMarsRover

Simple cocoa application that provides a visual implementation to the Thoughtworks Mars Rover problem
Objective-C
1
star