• Stars
    star
    320
  • Rank 131,126 (Top 3 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A helpful and very useful library for controller custom transition.Only an API can you finish many kind of animation for controller A to controller B.Though you don't understand any transition animations, it is ok!

                                                                

#English Document | 中文文档

A very helpful and an very useful library for controller custom transition.

This is an open source library for developers to use custom transition,
including push, pop, present and dismiss. In the library, now has supported
many kind of animations that we can see in many apps. The best thing for this
library is, that developers only need to call an API, without others, to support
custom transition. For more information, just see the document in detail
or just download the demo project to have a look.

#Goal

I design this library with a goal that any developer can use it directly without any knowledge
about custom transition. For this, I try to make it as easy as it can. Almost all properties
have default value, and just an API to call it out.

Though Developers have no foudation of custom transition, they can use it directly. All custom transition protocols have been wraped in the base transtion, you still can use it to add special effect. for this, just inherit from the HYBBaseTransition class.

#Version Changes

##Version 1.2.0

  • Fix in ios7, it shows wrong in Lanscape.
  • Add ease in ease out transition animations for push/pop、present/dismiss

##Version 1.1.0

  • fix a bug that it will be black when pushed to a controller and then go toHome, it means enter into background. Now I have set the navigation controller's delegate to nil when it was poped.

##Version 1.0.1

  • fix document

#Support Spring Animation

If you want to transition with Spring Animation, you can try this.

/**
 *	Default is NO, if set to YES, it will be presented and dismissed with
 *  spring animation.
 */
@property (nonatomic, assign) BOOL animatedWithSpring;

You can specify damp, initialSpringVerlocity, they have default values.

/**
 * The initial Spring velocity, Only when animatedWithSpring is YES, it will take effect.
 * Default is 1.0 / 0.5. If you don't know, just use the default value.
 */
@property (nonatomic, assign) CGFloat initialSpringVelocity;

/**
 *	The Spring damp, Only when animatedWithSpring is YES, it will take effect.
 *
 *  Default is 0.5. If you don't know, just use the default value.
 */
@property (nonatomic, assign) CGFloat damp;

#Buble Effect Transition

A custom modal transition that presents and dismiss a controller with an expanding bubble effect.
The bubble transition only supports present and dismiis mode.

image

It's easy to use, just in the presenting controller callback event to add custom transition, like below:

- (void)onPresent {
  HYBBubbleFromBottomController *vc = [[HYBBubbleFromBottomController alloc] init];
  vc.modalPresentationStyle = UIModalPresentationCustom;
  
  // Remember to own it strongly
  // Because delegate is weak reference, and it will be released after out of the function body.
  self.bubbleTransition = [[HYBBubbleTransition alloc] initWithPresented:^(UIViewController *presented, UIViewController *presenting, UIViewController *source, HYBBaseTransition *transition) {
    // You need to cast type to the real subclass type.
    HYBBubbleTransition *bubble = (HYBBubbleTransition *)transition;
   
    // If you want to use Spring animation, set to YES.
    // Default is NO.
    //    bubble.animatedWithSpring = YES;
    bubble.bubbleColor = presented.view.backgroundColor;
    
    // If one have a navigation bar but another not, you should handle the difference by yourself.
    CGPoint center = [self.view viewWithTag:1010].center;
    center.y += 64;
    
    bubble.bubbleStartPoint = center;
  } dismissed:^(UIViewController *dismissed, HYBBaseTransition *transition) {
    // Do nothing and it is ok here.
    // If you really want to do something, here you can set the mode.
    // But inside the super class, it is set to be automally.
    // So you do this has no meaning.
    transition.transitionMode = kHYBTransitionDismiss;
  }];
  vc.transitioningDelegate = self.bubbleTransition;
  
  [self presentViewController:vc animated:YES completion:NULL];
}

For example, AController has an event onPresent, when it is clicked, it will be invoked.
Now, AController needs to present BController, just use the code like above. In BController,
you don't need to do anything. It is easy?

For more information, you should see the properties provided, almost every property has default value.
So at many times, you don't need to worry about how to use.

#Modal Effect Transition

Modal transition animation, it will show usually half for the destination view controller's view,
and scale the from view.

It only supports present and dismiss mode.

image

It is easy to use just like bubble effect transition. Only use an API to finish your job. It looks like below:

- (void)onPresent {
  HYBBubbleFromBottomController *vc = [[HYBBubbleFromBottomController alloc] init];
  vc.modalPresentationStyle = UIModalPresentationCustom;
  
  // Remember to own it strongly
  // Because delegate is weak reference, and it will be released after out of the function body.
  self.bubbleTransition = [[HYBBubbleTransition alloc] initWithPresented:^(UIViewController *presented, UIViewController *presenting, UIViewController *source, HYBBaseTransition *transition) {
    // You need to cast type to the real subclass type.
    HYBBubbleTransition *bubble = (HYBBubbleTransition *)transition;
   
    // If you want to use Spring animation, set to YES.
    // Default is NO.
    //    bubble.animatedWithSpring = YES;
    bubble.bubbleColor = presented.view.backgroundColor;
    
    // If one have a navigation bar but another not, you should handle the difference by yourself.
    CGPoint center = [self.view viewWithTag:1010].center;
    center.y += 64;
    
    bubble.bubbleStartPoint = center;
  } dismissed:^(UIViewController *dismissed, HYBBaseTransition *transition) {
    // Do nothing and it is ok here.
    // If you really want to do something, here you can set the mode.
    // But inside the super class, it is set to be automally.
    // So you do this has no meaning.
    transition.transitionMode = kHYBTransitionDismiss;
  }];
  vc.transitioningDelegate = self.bubbleTransition;
  
  [self presentViewController:vc animated:YES completion:NULL];
}

For example, AController has an event onPresent, when it is clicked, it will be invoked.
Now, AController needs to present BController, just use the code like above. In BController,
you don't need to do anything. It is easy?

##Snapshot support navigation bar or not

When the presenting view controller has navigation bar, you should set it to YES, and default is YES.

/**
 *  Whether to include navigation bar when take scapshots.
 *	Default is YES. If NO, it has only the presenting view.
 */
@property (nonatomic, assign) BOOL scapshotIncludingNavigationBar;

##Support tap to dismiss automatically

If you don't want it to dismiss automatically, just set it to NO.
The default value is YES.

/**
 *	When tap on the presenting view, should it automatically is dismissed.
 *
 *  Default is YES.
 */
@property (nonatomic, assign) BOOL shouldDismissOnTap;

For more information, you should see the properties provided, almost every property has default value.
So at many times, you don't need to worry about how to use.

#Move Push/Pop Transition

The move transition animation, it looks like the transition animation of KeyNote move transition.
When click a cell or a subview, then push to a view controller and you need animation from the
clicked view to the destination controller.

It only supports push and pop mode.

image

For the custom push/pop transition animation, it is much harder than present/dismiss. The reason it that,
when a controller was pushed, at this time, we just call init method, but the target view to transition
is nil, so I have to try to solve this problem.

Now, I use a UIController category to solve it. In the pushed view controller, just set a target view like this:

// You must specify a target view with this.
self.hyb_toTargetView = imgView;

Now we use just like this:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  HYBMoveDetailController *vc = [[HYBMoveDetailController alloc] init];
  HYBGridModel *model = self.datasource[indexPath.item];
  vc.image = model.clipedImage;
  
  self.transition = [[HYBMoveTransition alloc] initWithPushed:^(UIViewController *fromVC, UIViewController *toVC, HYBBaseTransition *transition) {
    HYBMoveTransition *move = (HYBMoveTransition *)transition;
    HYBGridCell *cell = (HYBGridCell *)[collectionView cellForItemAtIndexPath:indexPath];
    move.targetClickedView = cell.imageView;
    
    move.animatedWithSpring = YES;
  } poped:^(UIViewController *fromVC, UIViewController *toVC, HYBBaseTransition *transition) {
    // Do nothing, unless you really need to.
  }];
  
  self.navigationController.delegate = self.transition;
  [self.navigationController pushViewController:vc animated:YES];
}

Here the example is that, when select a cell, transition from the cell's imageview to the target view (hyb_toTargetView).

Ok, until now, do you think it is really easy? I believe so!

#How to install

If your project supports Pod, just add the following code to you Podfile:

pod 'HYBControllerTransitions', '~> 1.0.0'

Otherwise, just add the source code HYBControllerTransitions folder to your project.

#Thanks

Thanks to andreamazz, I learn a lot from him.

#Contact

#MIT LICENSE

Copyright (c) 2016 CoderJackyHuang. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

HYBMasonryAutoCellHeight

A very helpful category for calculating the height of cell automatically.
Objective-C
680
star
2

HYBImageCliped

开源高效处理圆角的扩展,包括UIImageView、UIView、UIButton、UIImage的扩展API,可根据图片颜色生成图片带任意圆角,可给UIButton根据不同状态处理图片。所有生成图片都不会引起离屏渲染且不会引起离屏、图层混合,支持添加图片边框
Objective-C
639
star
3

HYBLoopScrollView

一行代码接入轮播组件,自带图片下载、缓存相关功能,无任何第三方依赖、轻量级组件。
Objective-C
625
star
4

HYBNetworking

基于AFNetworking3.0以上版本封装的网络层。提供常用的GET/POST接口、上传下载图片、文件接口、支持缓存等。
Objective-C
582
star
5

HYBHelperKit

日常开发必不可少的神器之一,UIBlockKit、UIMakerKit、UIKit、CommonKit、FoundationKit、Controllers、Constants等集于一身的神器!
Objective-C
448
star
6

HYBUnicodeReadable

解决打印日志对于Unicode编码不能正常显示中文的问题,只需要将文件导入工程,不需要引用,就能达到打印日志显示Unicode编码中文数据
Objective-C
354
star
7

MasonryDemo

学习Masonry各种用法
Objective-C
253
star
8

MDArtileFiles

241
star
9

WebViewJavascriptBridgeDemo

学习如何使用WebViewJavascriptBridge,配有详细的使用教程
Objective-C
154
star
10

IOSCallJsOrJsCallIOS

A good demo for iOS call js and js call ios native, using JavaScriptCore after iOS 7.0.
Objective-C
132
star
11

WKWebViewH5ObjCDemo

学习如何使用OC实现WKWebView与H5交互,并学习其API使用
Objective-C
101
star
12

DownloadManager

download demo
Objective-C
89
star
13

RuntimeDemo

学习Runtime
Objective-C
86
star
14

CollectionViewDemos

学习collectionview的所有例子,包括动画、布局等。
Objective-C
77
star
15

iOSLoadWebViewImage

Webview中的图片,使用ios原生来请求加载,然后使用webview显示
Objective-C
72
star
16

UIBezierPathLayerDemos

学习贝塞尔曲线及层动画相关
Objective-C
65
star
17

CellEmbedTableView

学习在cell中嵌套Tableview如何动态自动计算行高,自动适应内容的显示
Objective-C
58
star
18

HYBSnapkitAutoCellHeight

基于SnapKit写的自动计算cell的高度的扩展,对于喜欢纯代码自动布局的朋友们,你们有福利了
Swift
51
star
19

VideoCaptureDemo

VideoCaptureDemo
Objective-C
46
star
20

iOS-Socket-C-Version

学习OC的Socket编程,本demo是基于C语言原生API的
Objective-C
38
star
21

LocalPush

本地推送demo,处理了iOS8与IOS7之前的版本
Objective-C
37
star
22

CATransitionDemo

学习CATransition动画demo
Objective-C
36
star
23

NavigationBarScaleViewDemo

学习如何在系统的导航条上添加一个view,然后可以随着滚动而缩放。通常在很多的app中都采用了这种效果,主要是显示用户头像效果。
Objective-C
36
star
24

WKWebViewTestDemo

使用WKWebView
Swift
34
star
25

JokerMostRepository

Joker demo
Objective-C
26
star
26

StickyUpDownDemo

一个界面上有一个`headerView`、一个`toolbar`和一个`tableview`,在`tableview`向上滚动时,`headerView`和`toolbar`也向上移动,在`headerView`完全消失时,`toolbar`就固定在导航条下面,`tableview`就固定在`toolbar`下面。
Objective-C
26
star
27

HYBAttributedLabelCagegory

An very useful category of UILabel, for we can easily set style strings with HTML-like.
Objective-C
25
star
28

CALayerDemo

CALayer精讲对应的demo
Objective-C
24
star
29

PushPopTransitionDemo

学习Push/Pop转场效果
Objective-C
23
star
30

NavGestureDemo

验证如何同时支持leftBarButtonItem及右滑返回手势
Objective-C
22
star
31

ClockAnimationDemo

学习通过定时器和core animation来实现时钟动画
Objective-C
20
star
32

WebViewImgAutoFit

WebView加载HTML中的图片时,处理图片超过屏幕的问题,让图片自适应屏幕
Objective-C
20
star
33

SectionAnimation

利用UITableView的section实现像QQ那样的展开与收起的效果
Objective-C
18
star
34

BiaoGeMusicRepository

Objective-C
16
star
35

Charles_and_key

Charles 3.11.2及破解jar包
HTML
16
star
36

MultiSelectMutexDemo

在多选题处理中,A、B、C与D互斥和A与B互斥、C与D互斥学习如何处理。
Objective-C
16
star
37

IOSXMPPDemoByJackyHuang

实现了登录、注册、添加好友、删除好友、获取好友列表、发送消息、接收消息功能
Objective-C
13
star
38

ScrollViewAutolayoutDemo

使用sb/纯代码实现的自动布局demo,对新手很有帮助
Objective-C
12
star
39

ModalTransitionDemo

学习present/dismiss自定义转场动画
Objective-C
12
star
40

UITableViewEmbedUIWebViewDemo

UITableViewCell嵌入UIWebView,如何自适应高度问题学习
Objective-C
12
star
41

HYBTimerExtension

A convenience category of NSTimer.
Objective-C
10
star
42

HTMLImagePreviewDemo

HTML中点击图片预览
Objective-C
10
star
43

UMAnalyticsDemo

封装了友盟统计相关功能API,方便项目中调用
Objective-C
10
star
44

SwiftExtensionCodes

An extension of swift types, provided convenience api extension to use.
Swift
9
star
45

ITClient-Swift

IT JiangHu Client
Swift
9
star
46

SwiftImageView

use to download image and fade out when finished
Swift
9
star
47

BaiduMapDemo_v2.5.0

Objective-C
9
star
48

JPushDemo

极光推送简单应用
Objective-C
8
star
49

CollectionViewDemo

collection view demo
Objective-C
8
star
50

TextVeiw-Label-HTML-DEMO

练习UITextView和UILabel如何加载HTML内容
Objective-C
7
star
51

IOSAudioRemoteControl

Observe RemoteControl Event and handle it
Objective-C
6
star
52

iOSBlockUseDemo

尝试block内存引用问题
Objective-C
6
star
53

AppCommunicationDemo

学习应用之间如何互相调用,又如何传参数
Objective-C
6
star
54

HYBViewControllerCategory

扩展UIViewController,将常用的导航操作API、Tabbar API和NavigationBar API封装起来,适配iOS6.0及其以上版本
Objective-C
5
star
55

HLSStreamTools

HTTP Live Streaming segmenters tool.
4
star
56

PerformanceDemo

Objective-C
4
star
57

BlockDemos

学习block的所有demo
Objective-C
3
star
58

OSChinaIOSClient_Swift

OSChina ios client develop using swift
Objective-C
2
star
59

HYBUIViewExtension

an convenience category of UIView and a useful macro file
Objective-C
2
star
60

Swift2Demos

The demos of learning-swift2.0.
Swift
2
star
61

SwiftWeatherRepository

Using swift language to finish writing weather project
2
star
62

HYBDenyCrashKit

防止崩溃套件,对于测试和上线都很有用
1
star
63

UMessageDemo_Push

友盟推送测试demo
Objective-C
1
star
64

BiaoGeXMPPRepository

XMPP即时通讯类简单应用
Objective-C
1
star
65

HYBUIColorExtension

A convenience category of UIColor.
Objective-C
1
star
66

QueryPhoneDemo

PHP查询手机归属地小项目练习
PHP
1
star
67

HYBM3U8

正在开发中。。。
Objective-C
1
star
68

CollectionViewRepository

Using UICollectionView to layout views.
Objective-C
1
star
69

GCDDemos

学习GCD相关API的demo
Objective-C
1
star
70

SelectEmployeeDemo

Objective-C
1
star