Skip to content

Commit 6507eca

Browse files
committed
Update Readme
1 parent 725262b commit 6507eca

File tree

5 files changed

+273
-7
lines changed

5 files changed

+273
-7
lines changed

AnimationSwitchRootViewController/AnimationSwitchRootViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,14 @@ public extension UIWindow {
108108

109109

110110
/**
111-
Manually animation: move snaphots views (old and new).
111+
Manually animation: move snapshots views (old and new).
112112

113113
- Parameters:
114114
- rootViewController: ViewController to switch.
115115
- direction: Direction animation. Equal CATransitionSubType in CATransition.
116116
- inAnimation: Animation position for new ViewController.
117117
- outAnimation: Animation position for old ViewController.
118-
- duration: Duration animation. Default = 0.3.
118+
- duration: Duration animation. Default = 0.4.
119119
- options: UIViewAnimationOptions for UIView animations.
120120
*/
121121
@objc public func switchRootViewControllerManuallyMove(to rootViewController:UIViewController,

AnimationSwitchRootViewController/UIWindow+PVAnimationSwitchRootViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
1414
//Core Animation: transiction and temp background window
1515
- (void) setRootViewController:(UIViewController *)rootViewController withTransition:(CATransition*)transition backgroundColor:(nullable UIColor*)color andBackgroundView:(nullable UIView*)view;
1616

17-
//Manually animation: move snaphots
17+
//Manually animation: move snapshots
1818
- (void) setRootViewController:(UIViewController *)rootViewController withManuallyInAnimation:(BOOL)inAnimation outAnimation:(BOOL)outAnimation routeType:(NSString*)transitionSubType duration:(CGFloat)duration options:(UIViewAnimationOptions)options;
1919

2020

Example/Base.lproj/Main.storyboard

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
<view opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rCc-Vm-03k">
101101
<rect key="frame" x="16" y="351.5" width="343" height="307.5"/>
102102
<subviews>
103-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Manually move (snaphots)" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="MEt-cs-fF8">
103+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Manually move (snapshots)" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="MEt-cs-fF8">
104104
<rect key="frame" x="0.0" y="0.0" width="343" height="32"/>
105105
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle1"/>
106106
<nil key="textColor"/>
@@ -205,21 +205,21 @@
205205
<variation key="default">
206206
<mask key="constraints">
207207
<exclude reference="Lug-Ye-0lN"/>
208-
<exclude reference="awr-Jf-uIp"/>
209208
<exclude reference="F5z-Gx-bOZ"/>
210209
<exclude reference="wce-zA-bYR"/>
210+
<exclude reference="awr-Jf-uIp"/>
211211
</mask>
212212
</variation>
213213
<variation key="heightClass=compact">
214214
<mask key="constraints">
215215
<include reference="Lug-Ye-0lN"/>
216216
<exclude reference="Rfa-cH-ADA"/>
217217
<exclude reference="u3L-9t-Tgp"/>
218-
<include reference="awr-Jf-uIp"/>
219218
<include reference="F5z-Gx-bOZ"/>
220219
<exclude reference="KQa-ku-zjq"/>
221220
<exclude reference="kgE-dE-I3O"/>
222221
<include reference="wce-zA-bYR"/>
222+
<include reference="awr-Jf-uIp"/>
223223
</mask>
224224
</variation>
225225
</view>

README.md

Lines changed: 267 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,272 @@
55
[![Platform](https://cocoapod-badges.herokuapp.com/p/AnimationSwitchRootViewController/badge.png)](http://cocoapods.org/pods/AnimationSwitchRootViewController)
66
[![License](https://cocoapod-badges.herokuapp.com/l/AnimationSwitchRootViewController/badge.png)](https://github.com/ProVir/AnimationSwitchRootViewController/blob/master/LICENSE)
77

8-
Extension for UIWindow - animation switch rootViewController in UIWindow.
8+
Extension for UIWindow - animation switch rootViewController in UIWindow. Support Objective-C, Swift 3 and 4.
9+
If you need pure Objective-C, use AnimationSwitchRootViewControllerObjC.
10+
11+
[Example demo](https://github.com/ProVir/AnimationSwitchRootViewController/blob/master/demo.gif)
12+
13+
14+
- [Features](#features)
15+
- [Requirements](#requirements)
16+
- [Communication](#communication)
17+
- [Installation](#installation)
18+
- [Usage](#usage)
19+
- [Author](#author)
20+
- [License](#license)
21+
22+
23+
## Features
24+
25+
- [x] Change rootViewController in UIWindow with animation.
26+
- [x] Get main UIWindow from UIApplication static function sharedWindow().
27+
- [x] Support CATransaction with backgrounds color, UIVIew or UIImage.
28+
- [x] Support animation move snapshots (manually).
29+
30+
31+
32+
## Requirements
33+
34+
- iOS 8.0+
35+
- Xcode 8.1, 8.2, 8.3, and 9.0
36+
- Swift 3.0, 3.1, 3.2, and 4.0
37+
38+
39+
## Communication
40+
41+
- If you **need help**, go to [provir.ru](http://provir.ru)
42+
- If you **found a bug**, open an issue.
43+
- If you **have a feature request**, open an issue.
44+
- If you **want to contribute**, submit a pull request.
45+
46+
47+
48+
## Installation
49+
50+
### CocoaPods
51+
52+
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
53+
54+
```bash
55+
$ gem install cocoapods
56+
```
57+
58+
> CocoaPods 1.1.0+ is required to build AnimationSwitchRootViewController 1.0.0+.
59+
60+
To integrate WebServiceSwift into your Xcode project using CocoaPods, specify it in your `Podfile`:
61+
62+
```ruby
63+
source 'https://github.com/CocoaPods/Specs.git'
64+
platform :ios, '8.0'
65+
use_frameworks!
66+
67+
target '<Your Target Name>' do
68+
pod 'AnimationSwitchRootViewController', '~> 1.0'
69+
end
70+
```
71+
72+
Then, run the following command:
73+
74+
```bash
75+
$ pod install
76+
```
77+
78+
if you need pure Objective-C, use AnimationSwitchRootViewControllerObjC:
79+
```ruby
80+
pod 'AnimationSwitchRootViewControllerObjC', '~> 1.0'
81+
```
82+
83+
### Carthage
84+
85+
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
86+
87+
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
88+
89+
```bash
90+
$ brew update
91+
$ brew install carthage
92+
```
93+
94+
To integrate AnimationSwitchRootViewController into your Xcode project using Carthage, specify it in your `Cartfile`:
95+
96+
```ogdl
97+
github "ProVir/AnimationSwitchRootViewController" ~> 1.0
98+
```
99+
100+
Run `carthage update` to build the framework and drag the built `AnimationSwitchRootViewController.framework` into your Xcode project.
101+
102+
if you need pure Objective-C, use AnimationSwitchRootViewControllerObjC - drag the built `AnimationSwitchRootViewControllerObjC.framework` into your Xcode project.
103+
104+
105+
### Manually
106+
107+
If you prefer not to use any of the aforementioned dependency managers, you can integrate AnimationSwitchRootViewController into your project manually.
108+
109+
Copy files from directory `AnimationSwitchRootViewController` in your project.
110+
if you need pure Objective-C, don't copy `*.swift` files.
111+
112+
113+
---
114+
115+
## Usage
116+
117+
#### Interface in Swift (also Objective-C support):
118+
```swift
119+
public extension UIApplication {
120+
@objc public static func sharedWindow() -> UIWindow?
121+
}
122+
123+
public extension UIWindow {
124+
125+
///Transition Direction - equal CATransitionSubType.
126+
@objc public enum TransitionDirection : Int {
127+
case fromRight
128+
case fromLeft
129+
case fromTop
130+
case fromBottom
131+
}
132+
133+
/**
134+
Core Animation: custom transition and temp background window.
135+
136+
- Parameters:
137+
- rootViewController: ViewController to switch.
138+
- transition: Custom core animation transition.
139+
- backgroundColor: Background color when animation in process. Default is black.
140+
- backgroundView: View for background when animation in process.
141+
*/
142+
@objc public func switchRootViewController(to rootViewController: UIViewController,
143+
withTransition transition: CATransition,
144+
backgroundColor: UIColor? = nil,
145+
backgroundView: UIView? = nil)
146+
147+
148+
/**
149+
Core Animation: push transition and temp background window.
150+
151+
- Parameters:
152+
- rootViewController: ViewController to switch.
153+
- direction: Direction animation. Equal CATransitionSubType in CATransition.
154+
- duration: Duration animation. Default = 0.3.
155+
- backgroundColor: Background color when animation in process. Default is black.
156+
- backgroundView: View for background when animation in process.
157+
*/
158+
@objc public func switchRootViewControllerPushTransition(to rootViewController: UIViewController,
159+
direction: TransitionDirection,
160+
duration: CGFloat = 0.3,
161+
backgroundColor: UIColor? = nil,
162+
backgroundView: UIView? = nil)
163+
164+
/**
165+
Core Animation: push transition and temp background window with image as background.
166+
167+
- Parameters:
168+
- rootViewController: ViewController to switch.
169+
- direction: Direction animation. Equal CATransitionSubType in CATransition.
170+
- duration: Duration animation. Default = 0.3.
171+
- backgroundColor: Background color when animation in process. Default is black.
172+
- backgroundImage: Image for background when animation in process.
173+
*/
174+
@objc public func switchRootViewControllerPushTransition(to rootViewController: UIViewController,
175+
direction: TransitionDirection,
176+
duration: CGFloat = 0.3,
177+
backgroundColor: UIColor? = nil,
178+
backgroundImage: UIImage)
179+
180+
/**
181+
Manually animation: move snapshots views (old and new).
182+
183+
- Parameters:
184+
- rootViewController: ViewController to switch.
185+
- direction: Direction animation. Equal CATransitionSubType in CATransition.
186+
- inAnimation: Animation position for new ViewController.
187+
- outAnimation: Animation position for old ViewController.
188+
- duration: Duration animation. Default = 0.4.
189+
- options: UIViewAnimationOptions for UIView animations.
190+
*/
191+
@objc public func switchRootViewControllerManuallyMove(to rootViewController: UIViewController,
192+
direction: TransitionDirection,
193+
inAnimation: Bool = true,
194+
outAnimation: Bool = true,
195+
duration: CGFloat = 0.4,
196+
options: UIViewAnimationOptions = [])
197+
198+
}
199+
```
200+
201+
#### Interface in Objective-C only (also only support in `AnimationSwitchRootViewControllerObjC`):
202+
```objc
203+
204+
@interface UIApplication (PVRootWindow)
205+
+ (nullable UIWindow*) sharedWindow;
206+
@end
207+
208+
209+
@interface UIWindow (PVAnimationSwitchRootViewController)
210+
211+
//Core Animation: transition and temp background window
212+
- (void) setRootViewController:(UIViewController *)rootViewController
213+
withTransition:(CATransition*)transition
214+
backgroundColor:(nullable UIColor*)color
215+
andBackgroundView:(nullable UIView*)view;
216+
217+
218+
//Manually animation: move snapshots
219+
- (void) setRootViewController:(UIViewController *)rootViewController
220+
withManuallyInAnimation:(BOOL)inAnimation
221+
outAnimation:(BOOL)outAnimation
222+
routeType:(NSString*)transitionSubType
223+
duration:(CGFloat)duration
224+
options:(UIViewAnimationOptions)options;
225+
226+
227+
//Simplify function
228+
- (void) setRootViewController:(UIViewController *)rootViewController
229+
pushTransactionRoute:(NSString*)transitionSubType
230+
duration:(CGFloat)duration
231+
backgroundColor:(nullable UIColor*)color
232+
andBackgroundView:(nullable UIView*)view;
233+
234+
- (void) setRootViewController:(UIViewController *)rootViewController
235+
pushTransactionRoute:(NSString*)transitionSubType
236+
duration:(CGFloat)duration
237+
backgroundColor:(nullable UIColor*)color
238+
andBackgroundImage:(nullable UIImage*)image;
239+
240+
241+
242+
- (void) setRootViewController:(UIViewController *)rootViewController
243+
pushManuallyRoute:(NSString*)transitionSubType
244+
duration:(CGFloat)duration;
245+
246+
@end
247+
248+
```
249+
250+
251+
#### Example use in swift:
252+
```swift
253+
254+
UIApplication.sharedWindow()?.switchRootViewControllerPushTransition(to: newViewController,
255+
direction: .fromRight,
256+
backgroundColor: UIColor.white)
257+
258+
UIApplication.sharedWindow()?.switchRootViewControllerManuallyMove(to: newViewController,
259+
direction: .fromLeft)
260+
261+
```
262+
263+
More examples you can find in the project in this repository.
264+
265+
266+
267+
## Author
268+
269+
[**ViR (Короткий Виталий)**](http://provir.ru)
270+
271+
272+
## License
273+
274+
AnimationSwitchRootViewController is released under the MIT license. [See LICENSE](https://github.com/ProVir/AnimationSwitchRootViewController/blob/master/LICENSE) for details.
9275

10276

demo.gif

3.21 MB
Loading

0 commit comments

Comments
 (0)