Coder Social home page Coder Social logo

hgtransitionanimator's Introduction

HGTransitionAnimator

CocoaPods安装

  1. 在 Podfile 中添加 pod 'HGTransitionAnimator'。如果安装失败,请更新本地pod库pod repo update
  2. 执行 pod install 或 pod update。
  3. 导入UIViewController+HGAnimator.h

如何使用

导入头文件

#import "UIViewController+HGAnimator.h"

Present方法

// 使用封装的样式只需要调用这一句
OneViewController *oneVC=[[OneViewController alloc]init];
	[self hg_presentViewController:oneVC animateStyle:HGTransitionAnimatorFromLeftStyle  delegate:self presentFrame:_presentFrame backgroundColor:_backgroundColor animated:YES];	

Dismiss方法

// 必须掉用下面的dismiss,不要调用[self dismissViewControllerAnimated:YES completion:nil];
	[self hg_dismissViewControllerAnimated:YES completion:nil];

自定义需要做的:

实现HGTransitionAnimatorDelegate代理方法Transition
@interface ViewController ()	<HGTransitionAnimatorDelegate>
- (void)transitionAnimator:(HGTransitionAnimator *)animator animateTransitionToView:(UIView *)toView duration:(NSTimeInterval)duration{	// 弹出动画代码写在这里
}
- (void)transitionAnimator:(HGTransitionAnimator *)animator animateTransitionFromView:(UIView *)fromView duration:(NSTimeInterval)duration
{
	// 消失动画代码写在这里
}
- (NSTimeInterval)transitionDuration:(HGTransitionAnimator *)animator
{
    // 动画时间写在这里
}
- (BOOL)transitionAnimatorCanResponse:(HGTransitionAnimator *)animator
{
	// 蒙版点击是否有效
}
- (NSTimeInterval)transitionDuration:(HGTransitionAnimator *)animator
{
	//修改动画时间
}
// 更多代理方法详见demo

项目演示

查看并运行 HGTransitionAnimator/demo ,目前封装了11种基本样式.带手势识别dismiss的有3种,具体查看demo。

  • 左边弹出,类似于优步、滴滴的效果,带手势拖拽识别。
	animateStyle:HGTransitionAnimatorFromLeftStyle

(左边弹出1)

(左边弹出2)

  • 中心点消失
	animateStyle:HGTransitionAnimatorCenterStyle

(中心点消失)

  • 右边弹出
	animateStyle:HGTransitionAnimatorFromRightStyle

(右边弹出)

  • 显示隐藏
	animateStyle:HGTransitionAnimatorHiddenStyle

(显示隐藏)

  • 顶部出现
	animateStyle:HGTransitionAnimatorFromTopStyle

(顶部出现)

  • 底部出现
	animateStyle:HGTransitionAnimatorFromBottomStyle

(底部出现)

  • 垂直压缩
	animateStyle:HGTransitionAnimatorVerticalScaleStyle

(垂直压缩)

系统要求

该项目最低支持 iOS 8.0Xcode 7.0

注意

支持横竖屏的切换。使用控制器管理弹出视图的好处:面向协议编程,使控制器与View之间的传递控制链转换成控制器与控制器之间的传递,降低了代码的耦合度并且提高了代码的复用率,这也是Apple推出转场控制器的用意。如QQ右上角的添加分享界面的底部弹出、都可以用自带样式定义一个专属控制器,支持。目前有11种自带的样式,基本上可以满足日常的开发需求。如果自定义,请实现HGTransitionAnimatorDelegate代理方法。如果发现bug,请issue我,如果想改进,请pull request我!

许可证

HGTransitionAnimator 使用 MIT 许可证,详情见 LICENSE 文件。

hgtransitionanimator's People

Contributors

ixixii avatar zhahao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.