preface

A custom transition animation set was written during this time, and a variety of custom transitions can be implemented with just one line of code. This is the source address WXSTransition you can go to download to have a look, if you like the trouble to give a Star.

introduce

Transition Animation Asset A transition animation set.

In normal development, some transition animations are sometimes needed to add some vitality to the interface adjustment, and implementing these animations is relatively tedious. To make it easier to implement transitions, I wrote this interface transition animation set. Adjust the interface, as long as a line of code can achieve this animation. There are about 50 kinds of animations, including those provided by the system.

Method of use

Import the header file first

#import "UINavigationController+WXSTransition.h"

2, a line of code can be called

Push:

 [self.navigationController wxs_pushViewController:(UIViewController *) animationType:(WXSTransitionAnimationType)];Copy the code

Present:

[self wxs_presentViewController:(UIViewController *) animationType:(WXSTransitionAnimationType) completion:^{

}];Copy the code

WXSTransitionAnimationType is animated transitions type, through the selection of the enumeration transitions animation you want.

3. Support attribute modification
[self wxs_presentViewController:<#(uiviewcontroller *)#=""> makeTransition:^(WXSTransitionManager *transition) {
transition.animationType =  WXSTransitionAnimationTypePointSpreadPresent;
transition.animationTime = 1;
}];Copy the code

You can use transition to set the animation time, type, and other properties

4. Special calls

For animations like point Spread and ViewMoveToNextVC, you need a startView. Just point the startView of the target controller to this view.




view_move_next.gif

DetailViewController *vc = [[DetailViewController alloc] init];
CollectionViewCell *cell = (CollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
vc.startView = cell.imgView;
[self.navigationController wxs_pushViewController:vc makeTransition:^(WXSTransitionManager *transition) {
transition.animationType = WXSTransitionAnimationTypeViewMoveToNextVC;
transition.animationTime = 1;
}];Copy the code

Animation renderings

Custom animation



boom.gif




brick_close_H.gif




brick_open_V.gif




cover.gif




point_spread.gif




spread_from_right.gif




spread_from_top.gif




view_move_next.gif

System animation

IOS actually has a lot of good transitions, and it’s encapsulated in this transition set, just like custom transitions. Push:

[self.navigationController wxs_pushViewController:<#(uiviewcontroller *)#=""> animationType:<#(wxstransitionanimationtype)#>];Copy the code

Present:

[self wxs_presentViewController:<#(uiviewcontroller *)#=""> animationType:<#(wxstransitionanimationtype)#> completion:<#^(void)completion#>]Copy the code



sys_oglFlip.gif




sys_pageCurl.gif

After the language

Now is the first version, originally intended to support interactive gestures, but some animations using interactive gestures have many problems, so this version is removed, we are going to add some functions in the future version: Add some cool transition animation 2, support interactive gesture 3, provide custom animation interface, so that users want to achieve their own transition animation, do not need to achieve a variety of agents and other tedious work, focus on fromVC, and toVC animation logic.

Finally, the Gittub link. WXSTransition welcome to download and use, remember to give a star. If you have any ideas, you can exchange them and let us make progress together.