Skip to content
项目

coolbeet/CBStoreHouseTransition

在 GitHub 查看

关于

受 Storehouse iOS 应用启发的自定义转场,同时支持返回手势。

网站与应用开发

这些数字如何统计

可以做什么

  • One class file includes both pop and push transition and pop gesture.
  • Fully customizable transition animation.
  • UINavigationControllerpush and pop
  • UIViewControllerpresentations and dismissals

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

CBStoreHouseTransition

What is it?

A custom transition inspired by Storehouse iOS app, also support pop gesture.

![screenshot] (https://s3.amazonaws.com/suyu.test/CBStoreHouseTransition.gif)

Video

CBStoreHouseTransition

Features

  • One class file includes both pop and push transition and pop gesture.
  • Fully customizable transition animation.
  • Works for following iOS custom transition types:
    • UINavigationControllerpush and pop
    • UIViewControllerpresentations and dismissals

Which files are needed?

You only need to include CBStoreHouseTransition (.h .m) in your project, it contains both animator and interactive class.

CocoaPods support is coming very soon!

How to use it

For animator object you need to set proper AnimationType to match UINavigationControllerOperation object.

For interactive transition you need to attach current view controller using:

- (void)attachToViewController:(UIViewController *)viewController;

A edge pan gesture will be added on the view controller's root view to handle the pop gesture and drive the interactive transition.

Then just return the proper animatior or interactive object in related delegate method, following is a example using CBStoreHouseTransition for UINavigationController.

For more information about iOS custom transition, please refer to WWDC 2013 Custom Transitions Using View Controllers video.

- (void)viewDidLoad
{
    ...
    self.animator = [[CBStoreHouseTransitionAnimator alloc] init];
    ...
}

- (void)viewDidAppear:(BOOL)animated
{
    ...
    self.navigationController.delegate = self;
    self.interactiveTransition = [[CBStoreHouseTransitionInteractiveTransition alloc] init];
    [self.interactiveTransition attachToViewController:self];
    ...
}

-(id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                 animationControllerForOperation:(UINavigationControllerOperation)operation
                                              fromViewController:(UIViewController *)fromVC
                                                toViewController:(UIViewController *)toVC
{
    switch (operation) {
        case UINavigationControllerOperationPush:
            //we don't need interactive transition for push
            self.interactiveTransition = nil;
            self.animator.type = AnimationTypePush;
            return self.animator;
        case UINavigationControllerOperationPop:
            self.animator.type = AnimationTypePop;
            return self.animator;
        default:
            return nil;
    }
}

- (id<UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
                         interactionControllerForAnimationController:(id<UIViewControllerAnimatedTransitioning>)animationController
{
    return self.interactiveTransition;
}

Since we don't need interactive for push transition or when user specificity taps back button, you need to set self.interactive to nil.

You can customize following properties to change the animation behavior:

@property (nonatomic) CGFloat duration;
@property (nonatomic) CGFloat rotateAngle;
@property (nonatomic) CGFloat relativeDelayLeftView;
@property (nonatomic) CGFloat relativeDelayRightView;
@property (nonatomic) CGFloat percentageAdjustFactor;

探索相关项目

加载中…