Skip to content

Commit

Permalink
Add snapshot and update podspec.
Browse files Browse the repository at this point in the history
  • Loading branch information
yeatse committed Sep 20, 2016
1 parent 2fd4465 commit d34a49c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,40 @@

Yet another drop-in replacement of `UIPageViewController`, inspired by Apple's offical Music app.

## What problem does YTPageController try to resolve?

YTPageController introduces a general solution to achieve a smooth transition when user scrolls between view controllers, just as what Apple did in their Music app:

To implement this effect, just add these lines of code in your `YTPageControllerDelegate`:

```objectivec
- (void)pageController:(YTPageController *)pageController willTransitionToIndex:(NSInteger)index {
[pageController.pageCoordinator animateAlongsidePagingInView:self.segmentedControl animation:^(id<YTPageTransitionContext> _Nonnull context) {
// Update your segmented control according to the information contained in YTPageTransitionContext
self.segmentedControl.selectedSegmentIndex = [context toIndex];
} completion:^(id<YTPageTransitionContext> _Nonnull context) {
if ([context isCanceled]) {
// Revert to original state if transition canceled
self.segmentedControl.selectedSegmentIndex = [context fromIndex];
}
}];
}
```

The key idea to control the percent of its animation is to set the CALayer's `speed` property to 0, and then update the `timeOffset` value according to UIScrollView's `contentOffset`. In addition to `UISegmentedControl`, you can also animate `UITabBar` or any `UIView` subclass you like. Refer to the example project for detailed information.

## Example

To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Requirements

iOS 8.0 or above.
May be working from iOS 6.0, but I didn't test it.

## Installation

YTPageController is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
YTPageController is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile:

```ruby
pod "YTPageController"
Expand All @@ -33,3 +55,4 @@ Yeatse CC, [email protected]
YTPageController is available under the MIT license. See the LICENSE file for more info.



2 changes: 1 addition & 1 deletion YTPageController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
# * Finally, don't worry about the indent, CocoaPods strips it!

s.description = <<-DESC
Another drop-in replacement for UIPageViewController. You can run animations alongside the paging process. Fully storyboard support.
YTPageController introduces a general solution to archieve a smooth transitoin when user scrolls between view controllers, just as what Apple did in their Music App. With the help of YTPageController, you can implement the effect in a few lines.
DESC

s.homepage = 'https://github.com/yeatse/YTPageController'
Expand Down
Binary file added snapshot0.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d34a49c

Please sign in to comment.