• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 8 years ago

Reviews

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

Repository Details

Easy and tidy way for creating custom UIViewController transitions for iOS

AICustomViewControllerTransition

Easy and tidy way for creating custom UIViewController transitions for iOS

Create view controller transitions with no limits and without the complexity of implementing UIViewControllerAnimatedTransitioning protocol or subclassing UIPercentDrivenInteractiveTransition. You just need to use provided transitioningDelegate closure callbacks and provide your UIView animation code.

Platform Language License

Drag Down icon used in examples and screenshots is by IconMafia from thenounproject.com (https://thenounproject.com/search/?q=drag&i=463918)

##Requirements

  • iOS 8.1+
  • Xcode 8 (Use pod version 1.0.3 for Xcode 7)

Installation

Embedded frameworks require a minimum deployment target of iOS 8.1

To use with a project targeting iOS 7, or if you don't want to use CocoaPods you must include the AICustomViewControllerTransition.swift source file directly in your project.


Usage

1. Create a custom transitioning delegate object

  • SimpleTransitioningDelegate

If you don't want your transition to be interactive

let mySimpleTransitioningDelegate = SimpleTransitioningDelegate()
  • InteractiveTransitioningDelegate

If you want your transition to be interactive as well. Includes all the functionality of SimpleTransitioningDelegate

let myInteractiveTransitioningDelegate = InteractiveTransitioningDelegate()

2. Assign animation closures to your transitioning delegate

  • transitionPresent

Animate transition for presenting your modal view controller. See SimpleTransitionViewController example in the Example project.

mySimpleTransitioningDelegate.transitionPresent = { [weak self] (fromViewController: UIViewController, toViewController: UIViewController, containerView: UIView, transitionType: TransitionType, completion: @escaping () -> Void) in

	UIView.animate(withDuration: animationDuration, animations: {
		// Your custom presentation animation here
		// Use provided viewController views to animate
	}, completion: { (finished) in
		// Do't forget to execute completion closure
		completion()
	})
}
  • transitionDismiss

Animate transition for dismissing your modal view controller. See SimpleTransitionViewController example in the Example project.

mySimpleTransitioningDelegate.transitionDismiss = { [weak self] (fromViewController: UIViewController, toViewController: UIViewController, containerView: UIView, transitionType: TransitionType, completion: @escaping () -> Void) in

	UIView.animate(withDuration: animationDuration, animations: {
		// Your custom dismissal animation here
		// Use provided viewController views to animate
	}, completion: { (finished) in
		completion()
	})
}
  • transitionPercentPresent

Animate percent driven interactive transition for presenting your modal view controller. See PanToViewTransitionViewController and ExpandingCellsTableViewController examples in the Example project.

myInteractiveTransitioningDelegate.transitionPercentPresent = {[weak self] (fromViewController: UIViewController, toViewController: UIViewController, percentage: CGFloat, containerView: UIView) in
	// Animate your view controllers using provided percentage
	// Because the transition is progressive, you probably don't need an animation block here
}
  • transitionPercentDismiss

Animate percent driven interactive transition for dismissing your modal view controller. See PanToViewTransitionViewController and ExpandingCellsTableViewController examples in the Example project.

myInteractiveTransitioningDelegate.transitionPercentDismiss = {[weak self] (fromViewController: UIViewController, toViewController: UIViewController, percentage: CGFloat, containerView: UIView) in
	// Animate your view controllers using provided percentage
	// Because the transition is progressive, you probably don't need an animation block here
}

3. Begin, update and finalize a percent driven interactive transition

Use below methods if you are using an InteractiveTransitioningDelegate as your transitioning delegate. See PanToViewTransitionViewController and ExpandingCellsTableViewController examples in the Example project.

  • beginPresenting(viewController:fromViewController:) or beginDismissing(viewController:)

Begin presenting your modal view controller, usually in the callback method for a gesture recognizer that your user interacts with.

myInteractiveTransitioningDelegate.beginPresenting(viewController:myModalViewController, fromViewController:self)
  • update(_:)

Update the percentage of your transition, usually in the callback method for a gesture recognizer that your user interacts with.

myInteractiveTransitioningDelegate.update(percentage)
  • finalizeInteractiveTransition(isTransitionCompleted:)

End presenting or dismissing an interactive transition.

myInteractiveTransitioningDelegate.finalizeInteractiveTransition(isTransitionCompleted:true)

4. Present your view controller as usual

If you are not presenting your view controller in an interactive way, present your view controller as usual. Even if you are using an InteractiveTransitioningDelegate you can still choose to present or dismiss your view controller automatically without a progressive interaction from user, e.g. user taps the button only once. See PanToViewTransitionViewController in Example project.

myModalViewController.modalPresentationStyle = .Custom
myModalViewController.transitioningDelegate = myInteractiveTransitioningDelegate //or mySimpleTransitioningDelegate
self.presentViewController(self.detailViewController, animated: true, completion: nil)

Documentation

http://cocoadocs.org/docsets/AICustomViewControllerTransition/

License

AICustomViewControllerTransition is released under the MIT license. See LICENSE for details.

youtube, fancy

More Repositories

1

AIFlatSwitch

Nicely animated flat design switch alternative to UISwitch
Swift
981
star
2

Glide

Game engine for making 2d games on iOS, macOS and tvOS, with practical examples and tutorials
Swift
492
star
3

AIMapViewWrapper

use Google maps zoom level with MKMapView, animated route tracking with overlay views, and some other handy MKMapView functionality
Objective-C
30
star
4

CombineOperators

Interactive tutorial/cheat sheet app that lets you play with Combine framework publishers
Swift
28
star
5

StyledMarkdown

Generate SwiftUI Text or AttributedString from markdown strings with custom style names.
Swift
22
star
6

XMLText

Generate styled SwiftUI Text from strings with XML tags.
Swift
20
star
7

AISegmentedControl

a modular and fully customizable segmented control for iOS
Objective-C
3
star
8

AINavigationItemTitleLayoutView

an abstract class for correctly doing layout of UINavigationItem titleView subviews in iOS projects
Objective-C
2
star
9

AIReleaseToRefreshWrapper

a wrapper class for adding and managing release to refresh functionality to any scroll view in iOS
Objective-C
2
star
10

earthbound-narrative

A narrative flowchart from Earthbound(1994) game
JavaScript
2
star
11

glideTutorial-characterPlatform

glide engine tutorial where you can create a walking and jumping character on a platform πŸ“Ί
Swift
2
star
12

cocoatoucher.github.io

1
star
13

AIPickerViewWrapper

1
star
14

glideTutorial-2-inputIntro

glide engine tutorial where you can learn how to make touch control buttons and know more about input management in general πŸ“Ί
Swift
1
star