关于 iOS启动图的一些发现(子控制器切换)

最近看一个外文技术文章以及demo

提到一种实现,即:

自定义一个控制器R,这个控制器作为window的根控制器;

然后自定义一个控制器S,这个控制器作为启动图控制器,并且作为控制器R的子控制器;

然后自定义一个导航栏控制器(或者标签栏控制器)NB,这个控制器作为控制器R的子控制器过渡切换的目标子控制器,在这个

/*

  This method can be used to transition between sibling child view controllers. The receiver of this method is

  their common parent view controller. (Use [UIViewController addChildViewController:] to create the

  parent/child relationship.) This method will add the toViewController's view to the superview of the

  fromViewController's view and the fromViewController's view will be removed from its superview after the

  transition completes. It is important to allow this method to add and remove the views. The arguments to

  this method are the same as those defined by UIView's block animation API. This method will fail with an

  NSInvalidArgumentException if the parent view controllers are not the same as the receiver, or if the

  receiver explicitly forwards its appearance and rotation callbacks to its children. Finally, the receiver

  should not be a subclass of an iOS container view controller. Note also that it is possible to use the

  UIView APIs directly. If they are used it is important to ensure that the toViewController's view is added

  to the visible view hierarchy while the fromViewController's view is removed.

*/

- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))animations completion:(void (^__nullable)(BOOL finished))completionNS_AVAILABLE_IOS(5_0);

>>>>>>>>>>

Transitions between two of the view controller'€™s child view controllers.

 

This method adds the second view controller'€™s view to the view hierarchy and then performs the animations defined in your animations block. After the animation completes, it removes the first view controller'€™s view from the view hierarchy.

This method is only intended to be called by an implementation of a custom container view controller. If you override this method, you must call super in your implementation.


方法中的options

typedef NS_OPTIONS(NSUInteger, UIViewAnimationOptions) {

    UIViewAnimationOptionLayoutSubviews            = 1 << 0,

    UIViewAnimationOptionAllowUserInteraction      = 1 << 1,// turn on user interaction while animating

    UIViewAnimationOptionBeginFromCurrentState     = 1 << 2,// start all views from current value, not initial value

    UIViewAnimationOptionRepeat                    = 1 << 3,// repeat animation indefinitely

    UIViewAnimationOptionAutoreverse               = 1 << 4,// if repeat, run animation back and forth

    UIViewAnimationOptionOverrideInheritedDuration = 1 << 5,// ignore nested duration

    UIViewAnimationOptionOverrideInheritedCurve    = 1 << 6,// ignore nested curve

    UIViewAnimationOptionAllowAnimatedContent      = 1 << 7,// animate contents (applies to transitions only)

    UIViewAnimationOptionShowHideTransitionViews   = 1 << 8,// flip to/from hidden state instead of adding/removing

    UIViewAnimationOptionOverrideInheritedOptions  = 1 << 9,// do not inherit any options or animation type

    

    UIViewAnimationOptionCurveEaseInOut            = 0 <<16,// default

    UIViewAnimationOptionCurveEaseIn               = 1 <<16,

    UIViewAnimationOptionCurveEaseOut              = 2 <<16,

    UIViewAnimationOptionCurveLinear               = 3 <<16,

    

    UIViewAnimationOptionTransitionNone            = 0 <<20,// default

    UIViewAnimationOptionTransitionFlipFromLeft    = 1 <<20,

    UIViewAnimationOptionTransitionFlipFromRight   = 2 <<20,

    UIViewAnimationOptionTransitionCurlUp          = 3 <<20,

    UIViewAnimationOptionTransitionCurlDown        = 4 <<20,

    UIViewAnimationOptionTransitionCrossDissolve   = 5 <<20,

    UIViewAnimationOptionTransitionFlipFromTop     = 6 <<20,

    UIViewAnimationOptionTransitionFlipFromBottom  = 7 <<20,

} NS_ENUM_AVAILABLE_IOS(4_0);决定切换的方式



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值