https://github.com/yuwind/HHTransition
主流转场动画,无侵入,API简单易用。
https://github.com/yuwind/HHTransition
Last synced: 5 days ago
JSON representation
主流转场动画,无侵入,API简单易用。
- Host: GitHub
- URL: https://github.com/yuwind/HHTransition
- Owner: yuwind
- License: mit
- Created: 2018-04-23T02:52:23.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-08T05:46:45.000Z (about 1 year ago)
- Last Synced: 2025-04-04T04:47:46.410Z (about 1 month ago)
- Language: Objective-C
- Homepage:
- Size: 313 KB
- Stars: 845
- Watchers: 13
- Forks: 136
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-iOS - HHTransition - 主流转场动画,无侵入,API简单易用。 (UI Effects)
README
**主流转场动画**
### 1、HHTransition优势
1、API只有两个方法,易调用
2、面向切面编程,无侵入,不需要在VC中设置代理
3、易扩展,只需要重写转场对象即可
### 2、HHTransition不足
1、不够灵活,对于同一个转场对象无法设置不同的转场时间
2、如果需要传参,需要通过协议传递,漏写协议,编译时无法发现问题
### 3、类图

### 4、使用说明
#### 1、API使用
```objc
//present转场
- (void)hh_presentViewController:(UIViewController *)viewController presentStyle:(HHPresentStyle)presentStyle completion:(void (^__nullable)(void))completion
//push转场
- (void)hh_pushViewController:(UIViewController *)viewController style:(HHPushStyle)style;
```
例如:
```objc
[testViewController hh_presentViewController:viewController presentStyle:HHPresentStyleSlipFromTop completion:nil];
```
#### 2、扩展性
1、在`HHTransitionUtility`类下,增加枚举类型
2、增加转场对象,可以继承`HHBaseAnimatedTransition`,内部已做好分发
3、在类HHInteractionDelegate或者HHTransitioningDelegate下,根据枚举类型,设置transition对象
例如:
```objc
- (id)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;
}
}
```
```objc
- (id)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;
}
}
```**部分效果如下**




**2018-05-17增加CATransition动画**
---


**支持cocoapod**
```objc
target 'MyApp' do
pod 'HHTransition', '~> 3.1.2'
end
```