关于 iOS启动图的一些发现(子控制器切换)
2016-08-08 17:06
441 查看
最近看一个外文技术文章以及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);
>>>>>>>>>>
方法中的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);决定切换的方式
提到一种实现,即:
自定义一个控制器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 superin your implementation. |
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);决定切换的方式
相关文章推荐
- 学习iOS 黑魔法 笔记
- iOS调用系统的分享的两种方式
- iOS开发- runtime基本用法解析和用runtime给键盘添加工具栏和按钮响应事件
- 浅析iOS给图片加水印的方法
- iOS 十六进制转化为RGB值
- iOS-代码规范
- iOS-常用开发代码
- iOS 日志工具
- iOS OpenGL shader 语句字符串化
- iOS-规范-头文件结构
- 通过CAGradientLayer制作渐变色效果【原创】
- ios developer tiny share-20160808
- ios developer tiny share-20160808
- 软件测试,ios与安卓的区别
- iostat命令——监控系统设备的IO负载情况
- ios setNeedsDisplay和setNeedsLayout的区别与用处
- iOS9 新特性关键字(一)
- iOS OpenGL 纹理坐标详解
- iOS开发笔记>> Core Animation(核心动画)
- iOS应用内付费(IAP)开发步骤列表