{"id":22679821,"url":"https://github.com/provir/animationswitchrootviewcontroller","last_synced_at":"2025-03-29T13:42:40.616Z","repository":{"id":56902071,"uuid":"108728463","full_name":"ProVir/AnimationSwitchRootViewController","owner":"ProVir","description":"Extension for UIWindow - animation switch rootViewController in UIWindow.","archived":false,"fork":false,"pushed_at":"2021-04-24T10:08:32.000Z","size":2953,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-07T18:02:33.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProVir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-29T11:31:07.000Z","updated_at":"2022-11-14T10:47:11.000Z","dependencies_parsed_at":"2022-08-20T18:50:27.709Z","dependency_job_id":null,"html_url":"https://github.com/ProVir/AnimationSwitchRootViewController","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProVir%2FAnimationSwitchRootViewController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProVir%2FAnimationSwitchRootViewController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProVir%2FAnimationSwitchRootViewController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProVir%2FAnimationSwitchRootViewController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProVir","download_url":"https://codeload.github.com/ProVir/AnimationSwitchRootViewController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246193156,"owners_count":20738450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-09T19:10:57.474Z","updated_at":"2025-03-29T13:42:40.589Z","avatar_url":"https://github.com/ProVir.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AnimationSwitchRootViewController\n\n[![CocoaPods Compatible](https://cocoapod-badges.herokuapp.com/v/AnimationSwitchRootViewController/badge.png)](http://cocoapods.org/pods/AnimationSwitchRootViewController)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/ProVir/AnimationSwitchRootViewController)\n[![Platform](https://cocoapod-badges.herokuapp.com/p/AnimationSwitchRootViewController/badge.png)](http://cocoapods.org/pods/AnimationSwitchRootViewController)\n[![License](https://cocoapod-badges.herokuapp.com/l/AnimationSwitchRootViewController/badge.png)](https://github.com/ProVir/AnimationSwitchRootViewController/blob/master/LICENSE)\n\nExtension for UIWindow - animation switch rootViewController in UIWindow. Support Objective-C, Swift 5.\nIf you need pure Objective-C, use AnimationSwitchRootViewController/ObjC.\n\n![Example demo gif](https://github.com/ProVir/AnimationSwitchRootViewController/blob/master/demo.gif)\n\n\n- [Features](#features)\n- [Requirements](#requirements)\n- [Communication](#communication)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Author](#author)\n- [License](#license)\n\n\n## Features\n\n- [x] Change rootViewController in UIWindow with animation.\n- [x] Get main UIWindow from UIApplication static function sharedWindow().\n- [x] Support CATransaction with backgrounds color, UIVIew or UIImage.\n- [x] Support animation move snapshots (manually).\n\n\n\n## Requirements\n\n- iOS 8.0+\n- Xcode 10.2\n- Swift 5.0\n\n\n## Communication\n\n- If you **need help**, go to [provir.ru](http://provir.ru)\n- If you **found a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\n\u003e CocoaPods 1.6.0+ is required to build AnimationSwitchRootViewController 1.0.0+.\n\nTo integrate AnimationSwitchRootViewController into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\n\ntarget '\u003cYour Target Name\u003e' do\npod 'AnimationSwitchRootViewController', '~\u003e 1.0'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\nif you need pure Objective-C, use AnimationSwitchRootViewController/ObjC:\n```ruby\npod 'AnimationSwitchRootViewController/ObjC', '~\u003e 1.0'\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate AnimationSwitchRootViewController into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"ProVir/AnimationSwitchRootViewController\" ~\u003e 1.0\n```\n\nRun `carthage update` to build the framework and drag the built `AnimationSwitchRootViewController.framework` into your Xcode project.\n\nif you need pure Objective-C, use AnimationSwitchRootViewControllerObjC - drag the built `AnimationSwitchRootViewControllerObjC.framework` into your Xcode project.\n\n\n### Manually\n\nIf you prefer not to use any of the aforementioned dependency managers, you can integrate AnimationSwitchRootViewController into your project manually.\n\nCopy files from directory `AnimationSwitchRootViewController` in your project.\nif you need pure Objective-C, don't copy `*.swift` files.\n\n\n---\n\n## Usage\n\n#### Interface in Swift (also Objective-C support):\n```swift\npublic extension UIApplication {\n  @objc public static func sharedWindow() -\u003e UIWindow?\n}\n\npublic extension UIWindow {\n\n  ///Transition Direction - equal CATransitionSubType.\n  @objc public enum TransitionDirection : Int {\n    case fromRight\n    case fromLeft\n    case fromTop\n    case fromBottom\n  }\n\n  /**\n  Core Animation: custom transition and temp background window.\n\n  - Parameters:\n    - rootViewController: ViewController to switch.\n    - transition: Custom core animation transition.\n    - backgroundColor: Background color when animation in process. Default is black.\n    - backgroundView: View for background when animation in process.\n  */\n  @objc public func switchRootViewController(to rootViewController: UIViewController,\n                                             withTransition transition: CATransition,\n                                             backgroundColor: UIColor? = nil,\n                                             backgroundView: UIView? = nil)\n\n\n  /**\n  Core Animation: push transition and temp background window.\n\n  - Parameters:\n    - rootViewController: ViewController to switch.\n    - direction: Direction animation. Equal CATransitionSubType in CATransition.\n    - duration: Duration animation. Default = 0.3.\n    - backgroundColor: Background color when animation in process. Default is black.\n    - backgroundView: View for background when animation in process.\n  */\n  @objc public func switchRootViewControllerPushTransition(to rootViewController: UIViewController,\n                                                           direction: TransitionDirection,\n                                                           duration: CGFloat = 0.3,\n                                                           backgroundColor: UIColor? = nil,\n                                                           backgroundView: UIView? = nil)\n\n  /**\n  Core Animation: push transition and temp background window with image as background.\n\n  - Parameters:\n    - rootViewController: ViewController to switch.\n    - direction: Direction animation. Equal CATransitionSubType in CATransition.\n    - duration: Duration animation. Default = 0.3.\n    - backgroundColor: Background color when animation in process. Default is black.\n    - backgroundImage: Image for background when animation in process.\n  */\n  @objc public func switchRootViewControllerPushTransition(to rootViewController: UIViewController,\n                                                           direction: TransitionDirection,\n                                                           duration: CGFloat = 0.3,\n                                                           backgroundColor: UIColor? = nil,\n                                                           backgroundImage: UIImage)\n\n  /**\n    Manually animation: move snapshots views (old and new).\n\n  - Parameters:\n    - rootViewController: ViewController to switch.\n    - direction: Direction animation. Equal CATransitionSubType in CATransition.\n    - inAnimation: Animation position for new ViewController.\n    - outAnimation: Animation position for old ViewController.\n    - duration: Duration animation. Default = 0.4.\n    - options: UIViewAnimationOptions for UIView animations.\n  */\n  @objc public func switchRootViewControllerManuallyMove(to rootViewController: UIViewController,\n                                                         direction: TransitionDirection,\n                                                         inAnimation: Bool = true,\n                                                         outAnimation: Bool = true,\n                                                         duration: CGFloat = 0.4,\n                                                         options: UIViewAnimationOptions = [])\n                                                         \n}\n```\n\n#### Interface in Objective-C only (also only support in `AnimationSwitchRootViewControllerObjC`):\n```objc\n\n@interface UIApplication (PVRootWindow)\n  + (nullable UIWindow*) sharedWindow;\n@end\n\n\n@interface UIWindow (PVAnimationSwitchRootViewController)\n\n  //Core Animation: transition and temp background window\n  - (void) setRootViewController:(UIViewController *)rootViewController\n                  withTransition:(CATransition*)transition\n                 backgroundColor:(nullable UIColor*)color\n               andBackgroundView:(nullable UIView*)view;\n\n\n  //Manually animation: move snapshots\n  - (void) setRootViewController:(UIViewController *)rootViewController\n         withManuallyInAnimation:(BOOL)inAnimation\n                    outAnimation:(BOOL)outAnimation\n                       routeType:(NSString*)transitionSubType\n                        duration:(CGFloat)duration\n                         options:(UIViewAnimationOptions)options;\n\n\n  //Simplify function\n  - (void) setRootViewController:(UIViewController *)rootViewController\n            pushTransactionRoute:(NSString*)transitionSubType\n                        duration:(CGFloat)duration\n                 backgroundColor:(nullable UIColor*)color\n               andBackgroundView:(nullable UIView*)view;\n\n  - (void) setRootViewController:(UIViewController *)rootViewController\n            pushTransactionRoute:(NSString*)transitionSubType\n                        duration:(CGFloat)duration\n                 backgroundColor:(nullable UIColor*)color\n              andBackgroundImage:(nullable UIImage*)image;\n\n\n\n  - (void) setRootViewController:(UIViewController *)rootViewController\n               pushManuallyRoute:(NSString*)transitionSubType\n                        duration:(CGFloat)duration;\n\n@end\n\n```\n\n\n#### Example use in swift:\n```swift\n\nUIApplication.sharedWindow()?.switchRootViewControllerPushTransition(to: newViewController,\n                                                                     direction: .fromRight,\n                                                                     backgroundColor: UIColor.white)\n\nUIApplication.sharedWindow()?.switchRootViewControllerManuallyMove(to: newViewController,\n                                                                   direction: .fromLeft)\n\n```\n\nMore examples you can find in the project in this repository.\n\n\n\n## Author\n\n[**ViR (Короткий Виталий)**](http://provir.ru)\n\n\n## License\n\nAnimationSwitchRootViewController is released under the MIT license. [See LICENSE](https://github.com/ProVir/AnimationSwitchRootViewController/blob/master/LICENSE) for details.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprovir%2Fanimationswitchrootviewcontroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprovir%2Fanimationswitchrootviewcontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprovir%2Fanimationswitchrootviewcontroller/lists"}