Skip to content

Latest commit

 

History

History
90 lines (75 loc) · 4.17 KB

README.md

File metadata and controls

90 lines (75 loc) · 4.17 KB

主流转场动画

1、HHTransition优势

1、API只有两个方法,易调用
2、面向切面编程,无侵入,不需要在VC中设置代理
3、易扩展,只需要重写转场对象即可

2、HHTransition不足

1、不够灵活,对于同一个转场对象无法设置不同的转场时间
2、如果需要传参,需要通过协议传递,漏写协议,编译时无法发现问题

3、类图

4、使用说明

1、API使用

//present转场
- (void)hh_presentViewController:(UIViewController *)viewController presentStyle:(HHPresentStyle)presentStyle completion:(void (^__nullable)(void))completion
//push转场
- (void)hh_pushViewController:(UIViewController *)viewController style:(HHPushStyle)style;

例如:

[testViewController hh_presentViewController:viewController presentStyle:HHPresentStyleSlipFromTop completion:nil];

2、扩展性

1、在HHTransitionUtility类下,增加枚举类型
2、增加转场对象,可以继承HHBaseAnimatedTransition,内部已做好分发
3、在类HHInteractionDelegate或者HHTransitioningDelegate下,根据枚举类型,设置transition对象
例如:

- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
    switch (presented.presentStyle) {
        case HHPresentStyleNone:
            return nil;
        case HHPresentStyleSlipFromTop:
        case HHPresentStyleSlipFromBottom:
        case HHPresentStyleSlipFromLeft:
        case HHPresentStyleSlipFromRight:
            return [HHPresentFlipTransition flipTransitionWithStyle:presented.presentStyle isBegining:YES];
        default:
            return nil;
    }
}
- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    switch (dismissed.presentStyle) {
        case HHPresentStyleNone:
            return nil;
        case HHPresentStyleSlipFromTop:
        case HHPresentStyleSlipFromBottom:
        case HHPresentStyleSlipFromLeft:
        case HHPresentStyleSlipFromRight:
            return [HHPresentFlipTransition flipTransitionWithStyle:dismissed.presentStyle isBegining:NO];
        default:
            return nil;
    }
}

部分效果如下

121212.gif1.gif

2.gif3.gif

4.gif5.gif

6.gif7.gif

2018-05-17增加CATransition动画


transitionCube.giftransitionCurl.gif

transitionOgl.gif

支持cocoapod

target 'MyApp' do
  pod 'HHTransition', '~> 3.1.2'
end