Appstore card animation transition. UICollectionView and UITableView card expand animated transition

Overview

appstore-card-transition

Version License Xcode 10.0+ iOS 11.0+ Swift 5.0+

Appstore card animation transition. UICollectionView and UITableView card expand animated transition. This library tries to add the appstore transition to your own app. The goal is to be as simple as possible to integrate in an app while keeping the flexibility and customization alive.

Top dismissal

Bottom dismissal

How it works

appstore-card-transition uses the UIViewControllerTransitioningDelegate to implement the a custom transition animation. The initial frame of the selected cell is taken and the details view controller is animated from that position to the final expanded mode. Making sure that the expansion of the details view controller looks good falls in your responsability.

For closing the details view controller, gesture recognizers are used and the details view controller is animated back to the size of the cell, note that you can change the position of the cell while the details is shown to provide a more dynamic behaviour.

Most of the parameteres are customizable and callbacks for each meaningful action is provided.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate appstore-card-transition into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

target '' do
    pod 'appstore-card-transition'
end

Then, run the following command:

$ pod repo update
$ pod install

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but appstore-card-transition does support its use on supported platforms.

Once you have your Swift package set up, adding appstore-card-transition as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/appssemble/appstore-card-transition.git", from: "1.0.3")
]

Manual

Add the library project as a subproject and set the library as a target dependency. Here is a step by step that we recommend:

  1. Clone this repo (as a submodule or in a different directory, it's up to you);
  2. Drag AppstoreTransition.xcodeproj as a subproject;
  3. In your main .xcodeproj file, select the desired target(s);
  4. Go to Build Phases, expand Target Dependencies, and add AppstoreTransition;
  5. In Swift, import AppstoreTransition and you are good to go!

Basic usage guide

First make sure your cells implement the CardCollectionViewCell protocol.

extension YourCollectionViewCell: CardCollectionViewCell {    
    var cardContentView: UIView {
        get {
            return containerView
        }
    }
}

If you want your cells to also be responsive to touches, override the following methods:

    override func touchesBegan(_ touches: Set, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        animate(isHighlighted: true)
    }

    override func touchesEnded(_ touches: Set, with event: UIEvent?) {
        super.touchesEnded(touches, with: event)
        animate(isHighlighted: false)
    }

    override func touchesCancelled(_ touches: Set, with event: UIEvent?) {
        super.touchesCancelled(touches, with: event)
        animate(isHighlighted: false)
    }

Your cell is now all setup, now go to your details view controller and make it conform to the CardDetailViewController protocol.

extension YourDetailsViewController: CardDetailViewController {
    
    var scrollView: UIScrollView {
        return contentScrollView // the scrollview (or tableview) you use in your details view controller
    }
    
    
    var cardContentView: UIView {
        return headerView // can be just a view at the top of the scrollview or the tableHeaderView
    }

}

One more thing you need to hook in your details view controller. Make sure you call the dismissHandler in your scrollViewDidScroll:

    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        dismissHandler.scrollViewDidScroll(scrollView)
    }

Now you are ready to add the actual transition. In your cellForItemAt method, after you configured your cell as desired, make sure you set the following:

        cell.settings.cardContainerInsets = UIEdgeInsets(top: 8.0, left: 16.0, bottom: 8.0, right: 16.0) //set this only if your cardContentView has some margins relative to the actual cell content view.
        
        transition = CardTransition(cell: cell, settings: cell.settings) //create the transition
        viewController.settings = cell.settings //make sure same settings are used by both the details view controller and the cell
        //set the transition
        viewController.transitioningDelegate = transition
        viewController.modalPresentationStyle = .custom
        
        //actually present the details view controller
        presentExpansion(viewController, cell: cell, animated: true)

If you got here you should now have a basic appstore transition. It might not be perfect yet but its definitely a strong start. If something doesn't look well check if the constraints from your details view controller play well with resizing.

Tweaking and troubleshooting

Playing with the parameters: check the TransitionSettings class. Most common issues are animation glitches. To prevent those, make sure your constraints are properly set (especailly the top ones) and safe areas work as expected.

Next, make sure your cardContainerInsets are properly set and they reflect the actual ones from your cell.

Lastly, your scrollview might need some scrolling to match the actual cell look (it might need some more top inset than the cell for instance). For this case you can scroll the content as needed in your viewDidLoad method and for the dismiss animation you can use the dismissalScrollViewContentOffset property from TransitionSettings.

Customization

Most often than not, you'll want to animate some other content alongside the appstore animation. For this purpose action blocks are available. You can implement the following callbacks to receive changes in the transition progress.

extension YourDetailsViewController: CardDetailViewController {

    func didStartPresentAnimationProgress() { ... }
    func didFinishPresentAnimationProgress() { ... }
    
    func didBeginDismissAnimation() { ... }
    func didChangeDismissAnimationProgress(progress:CGFloat) { ... }
    func didFinishDismissAnimation() { ... }
    func didCancelDismissAnimation(progress:CGFloat) { ... }
    
}

Example

Checkout the demo project to see some examples of what the library can do and how its done.

Contribute

We're aware that this is far from perfect so any improvement or feature is welcomed. If you made an awesome change don't hesitate to create a pull request.

This project is inspired from this project

Let us help you

Do you need help with your app development? Drop us a line



Comments
  • Can't use card transition within TabBarController [Not Fixed]

    Can't use card transition within TabBarController [Not Fixed]

    After implementing fix suggested here - 399705d still facing same issue if presenting from CollectionView Cell inside TabBarController. I'm using Xcode 11.3.1, Swift 5.1, iOS 13.3

    image

    opened by tarastomchuk 11
  • Crash while using a UITabBarController

    Crash while using a UITabBarController

    Looking at the demo application, if I re-create the "type2" animation inside of a view controller that's managed by a UITabBarController, the animation fails with the following error message:

    Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file AppstoreTransition/PresentCardAnimator.swift, line 97

    When diving into the code, it appears that when presenting with self.present inside of a UITabBarController, the view controller itself does not handle it, but the tab bar controller. Eg, calling:

    ctx.viewController(forKey: .from)

    returns a UITabBarController, not the CardsViewController as expected. This same thing could probably happen if the view controller is in a UINavigationController.

    opened by mknippen 1
  • Can't use card transition within TabBarController

    Can't use card transition within TabBarController

    If a collection view controller is in TabBarController, the app will crashed when try to transition from collectionView to detail view.

    Screen Shot 2019-10-11 at 10 54 31

    But, if I don't use TabBarController, the app will work correctly when try to transition from collectionView to a detail view.

    Maybe I missed something or appstore-card-transition don't support TabBar for now?

    opened by ArdoThenardo 1
  • Import UIKit to fix build error with Swift Package Manager

    Import UIKit to fix build error with Swift Package Manager

    When using Swift Package Manager to use this project in another one, two files had build errors. These were UIKit extension files that imported Foundation but not UIKit.

    Additionally, this changeset fixes some build warnings (var vs. let, unused variables, etc.).

    opened by cradnovich 0
  • Doesn't dismiss on first swipe

    Doesn't dismiss on first swipe

    After the transition is complete the first swipe down to dismiss the View isn't recognised. If I swipe again it works or if I scroll up then slide down to dismiss it works.

    opened by junaidxabd 0
  • detail card has zero size

    detail card has zero size

    if you present some viewcontroller from a detailed card and return, then the detailed card has a zero size and that's all because cardDetailView.translatesAutoresizingMaskIntoConstraints = false, need cardDetailView.translatesAutoresizingMaskIntoConstraints = true into func completeEverything() `

             func completeEverything() {
    		animatedContainerView.removeConstraints(animatedContainerView.constraints)
    		animatedContainerView.removeFromSuperview()
    		
    		container.addSubview(cardDetailView)
    		
    		cardDetailView.removeConstraints([topTemporaryFix, cardWidthConstraint, cardHeightConstraint])
    		
    		cardDetailView.edges(to: container)
    		cardDetailView.translatesAutoresizingMaskIntoConstraints = true
    		
    		screens.cardDetail.scrollView.isScrollEnabled = true
    		
    		let success = !ctx.transitionWasCancelled
    		ctx.completeTransition(success)
    		
    		screens.cardDetail.didFinishPresentAnimationProgress()
    	}
    

    `

    opened by di18s 1
  • Crash on cell Getting

    Crash on cell Getting

       `private func showType2(indexPath: IndexPath, bottomDismiss: Bool = false) {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: "type2") as! Type2ViewController
        
        // Get tapped cell location
        let cell = tableview.cellForRow(at: indexPath) as? CardCollectionViewCell
        cell!.settings.cardContainerInsets = UIEdgeInsets(top: 8.0, left: 16.0, bottom: 8.0, right: 16.0)
        cell!.settings.isEnabledBottomClose = bottomDismiss
        
        transition = CardTransition(cell: cell!, settings: cell!.settings)
        viewController.settings = cell!.settings
        viewController.transitioningDelegate = transition
        
        // If `modalPresentationStyle` is not `.fullScreen`, this should be set to true to make status bar depends on presented vc.
        //viewController.modalPresentationCapturesStatusBarAppearance = true
        viewController.modalPresentationStyle = .custom
        
        presentExpansion(viewController, cell: cell!, animated: true)
    }`
    

    "Fatal error: Unexpectedly found nil while unwrapping an Optional value: file- cell is getting nil"

    opened by veersr9 4
Releases(1.0.4)
Owner
appssemble
We design and develop mobile apps that help your business grow.
appssemble
Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

IBAnimatable 8.6k Jan 2, 2023
ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation

ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation. Demo Requirements iOS 9.0+ Xcode 8 Insta

Yansong Li 775 Dec 7, 2022
ZoomTransitioning provides a custom transition with image zooming animation and swiping the screen edge.

ZoomTransitioning Overview ZoomTransitioning provides a custom transition with image zooming animation. When you use this library with UINavigationCon

WorldDownTown 673 Dec 27, 2022
Transition animation for ViewController

XTransitionKit Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 9.0+ Swift 5

Leo 2 Dec 17, 2021
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

Gordan Glavaš 9 Nov 5, 2022
Simple Interface Core Animation. Run type-safe animation sequencially or parallelly

Simple Interface Core Animation Sica can execute various animations sequentially or parallelly. Features Animation with duration and delay parallel /

CATS Open Source Softwares 1k Nov 10, 2022
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Mostafa Abdellateef 7 Jan 2, 2023
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023
A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.

AnimatedCollectionViewLayout Normally a UICollectionView has no transition effects when you scroll from one item to another. There are lots of ways to

Jin Wang 4.5k Jan 1, 2023
Presentation helps you to make tutorials, release notes and animated pages.

Presentation helps you to make tutorials, release notes and animated pages.

HyperRedink 3k Dec 28, 2022
Simple and powerful animated progress bar with dots

Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 8.0+ Swift 3.0+ Installatio

Nikola Corlija 42 Dec 5, 2022
SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image

SwiftUI.AnimatedImage SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image Screen.Recording.2021-07-31.at.02.18.33.mov Insta

Marcin Krzyzanowski 50 Oct 14, 2022
ButtonClickStyle - This is a Customizable/Designable Button View, with 15 animated click styles, that allows you to design your own buttons from subviews, in storyboard and xib right away.

ButtonClickStyle - This is a Customizable/Designable Button View, with 15 animated click styles, that allows you to design your own buttons from subviews, in storyboard and xib right away.

Rustam 25 Oct 10, 2022
Keynote-style Magic Move transition animations

MagicMove All the magic of Keynote Magic Move transitions brought to iOS. Demo Magic Move Transition Spin Transition Fade Transition TODO MagicMove Tr

Patrick Reynolds 15 Sep 6, 2018
Create a smooth transition between any two SwiftUI Views

GZMatchedTransformEffect Create a smooth transition between any two SwiftUI Views. It is very similar to the built-in .matchedGeometryEffect() modifie

Gong Zhang 10 Nov 26, 2022
iOS framework for impressive transition animations between views.

CoreTransition iOS framework for impressive transition animations between views. Built using Swift, and supports a lot of animations to navigate to a

Ahmed Abdelkarim 4 Nov 17, 2022
A simple animated progress bar in Swift

DSGradientProgressView Introduction DSGradientProgressView is a simple and customizable animated progress bar written in Swift. Inspired by GradientPr

Dhol Studio 445 Oct 13, 2022
🚀 It Makes easy to track your task 🔥 Beautiful & Animated UI👨🏻‍💻 . Contributions are always welcome 🤗

Taskey ?? What is Taskey ?? ? Taskey is an application build in SwiftUI to track your task with a beautiful animations and UI . Also used core data to

Mohd Yasir 36 Nov 20, 2022