All Projects → malcommac → Uiwindowtransitions

malcommac / Uiwindowtransitions

Licence: mit
🏃‍♂️ Animated transitions for UIWindow's rootViewController property

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Uiwindowtransitions

Starwars.ios
This component implements transition animation to crumble view-controller into tiny pieces.
Stars: ✭ 3,685 (+758.97%)
Mutual labels:  uikit
Acknowlist
Acknowledgements screen displaying a list of licenses, for example from CocoaPods dependencies.
Stars: ✭ 392 (-8.62%)
Mutual labels:  uikit
Cards
Awesome iOS 11 appstore cards in swift 5.
Stars: ✭ 4,017 (+836.36%)
Mutual labels:  uikit
Epoxy Ios
Epoxy is a suite of declarative UI APIs for building UIKit applications in Swift
Stars: ✭ 377 (-12.12%)
Mutual labels:  uikit
Stepslider
StepSlider its custom implementation of slider such as UISlider for preset integer values.
Stars: ✭ 391 (-8.86%)
Mutual labels:  uikit
Squishbutton
A button that squishes when pressed. As seen in the Clips app.
Stars: ✭ 401 (-6.53%)
Mutual labels:  uikit
Overwatch Ui
A UI library of Overwatch, built with Vue.js
Stars: ✭ 365 (-14.92%)
Mutual labels:  uikit
Uikit Cross Platform
Cross-platform Swift implementation of UIKit, mostly for Android
Stars: ✭ 421 (-1.86%)
Mutual labels:  uikit
Tlyshynavbar
Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars!
Stars: ✭ 3,780 (+781.12%)
Mutual labels:  uikit
Uicollectionview Layouts Kit
📐 A set of custom layouts for UICollectionView with examples [Swift 5.3, iOS 12].
Stars: ✭ 410 (-4.43%)
Mutual labels:  uikit
Fluttergrocery Shoppingappui
🍔😋 Grocery Shopping App template UI kit in Flutter
Stars: ✭ 388 (-9.56%)
Mutual labels:  uikit
Shadowview
An iOS Library that makes shadows management easy on UIView.
Stars: ✭ 391 (-8.86%)
Mutual labels:  uikit
Restaurantappuikit
Flutter representation of a full Restaurant app UI KIT.
Stars: ✭ 400 (-6.76%)
Mutual labels:  uikit
Awesome Flutter Ui
10+ flutter(android, ios) UI design examples ⚡️ - login, books, profile, food order, movie streaming, walkthrough, widgets
Stars: ✭ 372 (-13.29%)
Mutual labels:  uikit
Tweetextfield
Lightweight set of text fields with nice animation and functionality. 🚀 Inspired by https://uimovement.com/ui/2524/input-field-help/
Stars: ✭ 421 (-1.86%)
Mutual labels:  uikit
Sancho
Responsive and accessible React UI components built with Typescript
Stars: ✭ 365 (-14.92%)
Mutual labels:  uikit
Swiftuikitview
Easily use UIKit views in your SwiftUI applications. Create Xcode Previews for UIView elements
Stars: ✭ 398 (-7.23%)
Mutual labels:  uikit
Keyboardguide
A modern, real iOS keyboard system notifications handler framework that Just Works.
Stars: ✭ 424 (-1.17%)
Mutual labels:  uikit
Owl
A declarative type-safe framework for building fast and flexible lists with UITableViews & UICollectionViews
Stars: ✭ 423 (-1.4%)
Mutual labels:  uikit
Panelkit
PanelKit is a UI framework that enables panels on iOS. A panel can be presented in the following ways:
Stars: ✭ 3,835 (+793.94%)
Mutual labels:  uikit

UIWindowTransitions

Animate UIWindow's rootViewController transitions

This is a small project used to demostrate how to implement UIWindow's rootViewController transitions with a little piece of code. You can found the original article for this article here.

Motivation

Sometimes during the lifecycle of an application you may need to change the rootViewController of your main UIWindow ; a typical case maybe the transition between the initial on-boarding and the home of the app (ie. a UITabBarController ).

In order to handle this edge case you may want to create a top controller (typically an UINavigationController with invisible navigation bar) which enable you to push your new container using a standard push animation.

While basically it works fine, the addition of a container used only to handle this single operation is a bit awful to see.

A way better solution is to apply an animated transition (push/pop or slide) to the rootViewController set so you will get an animate switch from the current view controller to the new one.

In fact, even if not exposed, you can and its really simple to accomplish via CoreAnimation and CATransition .

The following code implements a new function as extension of UIWindow class; it takes two arguments: the destination controller and options.

As you may imagine the destination controller is the controller you want to set as new rootViewController, while options is struct used to group some typical CoreAnimation settings: the animation direction (pop/push/slide from top or bottom), the animation curve (linear, ease in/out), the duration of the animation (by default is 0.25s) and an optional UIView instance used to fade in/out between the old and new view.

Known Issue & Fix

The 1.0.0 fixes and issue with iOS currently opened as radar here. This fix was created by voltbank in his repository ReplaceRootViewController forked from this project.

❤️ Your Support

Hi fellow developer!
You know, maintaing and developing tools consumes resources and time. While I enjoy making them your support is foundamental to allow me continue its development.

If you are using SwiftLocation or any other of my creations please consider the following options:

How to use it

Once implemented you can use the only function exposed to all UIWindow instances called

func set(rootViewController newRootViewController: UIViewController, options: TransitionOptions = TransitionOptions(), _ completion:((Bool) -> Void)? = nil)

where:

  • controller: the destination view controller to set as new rootViewController
  • options: a TransitionOptions with the following properties:
    • duration: duration of the animation (expressed in TimeInterval, seconds, default is 0.25)
    • direction: direction of the transition (toRight,toLeft,toTop,toBottom, default is .toRight)
    • style: animation curve (linear,easeIn,easeOut,easeInOut, default is .linear)
    • background: background view set for fade in-out into the old/new controller (by default is nil).
  • completion: completion callback to receive info when transition did completes.

The following code change the rootViewController using a ease out - slide up animation of 0.4 seconds.

let wnd = UIApplication.shared.keyWindow
var options = UIWindow.TransitionOptions()
options.direction = .toTop
options.duration = 0.4
options.style = .easeOut
wnd?.set(rootViewController(newVC, options: options)

If you just need of a simple push (like UINavigationController's push) you can call it without the options arg:

wnd?.set(rootViewController(newVC)

Demo App

The following demo is available inside the project's demo application.

Installation

You can install UIWindowTransitions using CocoaPods, Carthage and Swift package manager

pod 'UIWindowTransitions'

CocoaPods

use_frameworks!
pod 'UIWindowTransitions'

Swift Package Manager

Add UIWindowTransitions as dependency in your Package.swift

import PackageDescription

let package = Package(name: "YourPackage",
	dependencies: [
		.Package(url: "https://github.com/malcommac/UIWindowTransitions.git", majorVersion: 0),
	]
)

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Copyright & Acknowledgements

UIWindowTransitions is currently owned and maintained by Daniele Margutti.
You can follow me on Twitter @danielemargutti.
My web site is https://www.danielemargutti.com

This software is licensed under MIT License.

Follow me on:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].