{"id":13696990,"url":"https://github.com/LoongerTao/TLTransitions","last_synced_at":"2025-05-03T17:33:02.090Z","repository":{"id":56922990,"uuid":"155139847","full_name":"LoongerTao/TLTransitions","owner":"LoongerTao","description":"快速实现控制器的转场和View的快速popover显示，并支持自定义动画、手势退场","archived":false,"fork":false,"pushed_at":"2020-03-27T09:13:37.000Z","size":19779,"stargazers_count":330,"open_issues_count":4,"forks_count":48,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-11T01:41:41.949Z","etag":null,"topics":["actionsheet","alert","animation","animator","catransition","ios","modal","popover","popview","present","presentviewcontroller","push","transition","transition-animation","vc-animator"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LoongerTao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-29T02:27:32.000Z","updated_at":"2025-03-24T02:02:01.000Z","dependencies_parsed_at":"2022-08-20T22:20:15.540Z","dependency_job_id":null,"html_url":"https://github.com/LoongerTao/TLTransitions","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoongerTao%2FTLTransitions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoongerTao%2FTLTransitions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoongerTao%2FTLTransitions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LoongerTao%2FTLTransitions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LoongerTao","download_url":"https://codeload.github.com/LoongerTao/TLTransitions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252226970,"owners_count":21714914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actionsheet","alert","animation","animator","catransition","ios","modal","popover","popview","present","presentviewcontroller","push","transition","transition-animation","vc-animator"],"created_at":"2024-08-02T18:00:51.094Z","updated_at":"2025-05-03T17:33:02.084Z","avatar_url":"https://github.com/LoongerTao.png","language":"Objective-C","funding_links":[],"categories":["UI Effects"],"sub_categories":[],"readme":"# TLTransitions\n\n### pod支持\n##### 1. 版本 \n```\npod 'TLTransitions', '~\u003e 1.5.1'\n```\n\n##### 2. CocoaPods获取不到最新的`TLTransitions`版本问题\n这可能是本地的CocoaPods仓库列表没有更新导致的。\n\n1. 运行以下命令更新本地的CocoaPods仓库列表：\n``` pod repo update ```\n\n2. 然后通过以下命令查询\n``` pod search TLTransitions ```\n\n3. 如果仍然查询不到最新版本，可以删除本地仓库重新安装\n```sudo rm -rf ~/.cocoapods/repos/master pod setup```\n\n\n### **1. 目的**\n让繁琐的个性化控制器的转场(present/pop)和视图弹窗实现，变的简单快速（一句代码或几行即可搞定），并支持动画的自定义，支持通过手势转场（dismiss/pop）\n\n### **2. 实现基础** \n- 控制器的转场基于协议`UIViewControllerTransitioningDelegate`,`UINavigationControllerDelegate`，`UIViewControllerAnimatedTransitioning`\n - View弹窗则是通过控制器的转场包装而来，同时还基于`UIPresentationController`\n\n### **使用与说明**\n####  1. View弹窗：\n- 使用：对应`TLTransition`类的API，只要一行代码即可将一个已有的View进行显示，使用如下（更多使用见`TLTransition.h` 中的API 或 Demo)）\n```objc\n// popView是一个用户自定义的视图，并且已经设置好布局\n[TLTransition showView:popView popType:TLPopTypeAlert];\n```\n\n- 可实现如下效果：\n    - 图1. 系统Alert样式的中间弹窗，并支持键简单的盘高度自适应（可关闭）\n    - 图2. 系统Action Sheet样式的底部弹窗\n    - 图3. 将一个view显示到指定的位置\n    - 图4. 将一个view从frame1动画到frame2\n    - 图5. 动画自定义，提供block将自定义动画传入即可\n    \n ![alert.gif](https://upload-images.jianshu.io/upload_images/3333500-a1862b84e09c65cd.gif?imageMogr2/auto-orient/strip)\n ![actionSheet.gif](https://upload-images.jianshu.io/upload_images/3333500-b6f9d07cd39f6347.gif?imageMogr2/auto-orient/strip)\n ![point.gif](https://upload-images.jianshu.io/upload_images/3333500-8400581effaabdaa.gif?imageMogr2/auto-orient/strip)\n ![frame.gif](https://upload-images.jianshu.io/upload_images/3333500-ada674cbd225e62d.gif?imageMogr2/auto-orient/strip)\n ![customforview.gif](https://upload-images.jianshu.io/upload_images/3333500-1036eb2a60e89ae4.gif?imageMogr2/auto-orient/strip)\n\n- 其他API\n1. 动态更新size（效果如上面ActionSheet样式所示，仅限size，不能改变位置）\n\n```objc\n// 实时更新view的size ，显示后也可以更新\n- (void)updateContentSize;\n\n// 使用\nCGRect rect = _bView.bounds;\nrect.size.height += 1;\n_bView.bounds = rect;\n[_transition updateContentSize];\n```\n2. 手动dismiss(正常情况通过点击灰色区域进行dismiss，无需手动调用API)\n```objc\n/**\n * 隐藏popView\n * 如果TLTransition没有被引用，则在隐藏后会自动释放\n * 如果popView没有被引用，在隐藏后也会自动释放\n */\n- (void)dismiss;\n\n// 使用\n[_transition dismiss];\n```\n\n#### 2. UIViewController转场：\n- 控制器转场思维结构图\n   ![思维结构图](https://upload-images.jianshu.io/upload_images/3333500-58489f3c2cb8e169.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)\n - API:\n1. 所在类：分类`UIViewController+Transitioning`和遵守`TLTLAnimatorProtocol`协议的`Animator`类\n2. 支持多种模式的动画(具体API见上述类头文件)：\n  - present：`系统原生转场动画`（非自定义转场）、`Swipe系列`、`CATransition系列动画` 、`Cunstom Block模式`、`案例锦集`\n - push：`Swipe系列`、`CATransition系列` 、`Cunstom模式`、`案例锦集`\n3. 支持自定义动画[Animator]（`非Cunstom模式`）\n只要基于`TLTLAnimatorProtocol`协议即可，具体实现可参考模版`TLAnimatorTemplate`里面有一些思路与注意事项\n4. 所以类型API都默认支持侧滑手势dismiss/pop，可以关闭（如果要手动dismiss/pop，只需调用原生API即可）\n4. 部分转场效果图\n- 图1. 原生present  \n- 图2.Swipe \n- 图3.CATransition \n- 图4.Cunstom\n- 图5.锦集 (部分)\n- 图6.锦集-圆形缩放 \n- 图7.锦集-抽屉效果 \n- 图8.轻仿App store Card动画\n- 其它效果（见demo）：发牌效果、轻缩放（小程序转场效果）...\n![system.gif](https://upload-images.jianshu.io/upload_images/3333500-40355d0619cbb726.gif?imageMogr2/auto-orient/strip)\n![swipe.gif](https://upload-images.jianshu.io/upload_images/3333500-080df94e9d1cd8ec.gif?imageMogr2/auto-orient/strip)\n![CATransition.gif](https://upload-images.jianshu.io/upload_images/3333500-6b16c504fca3dbca.gif?imageMogr2/auto-orient/strip)\n![custom.gif](https://upload-images.jianshu.io/upload_images/3333500-8727ef6aadda6a5d.gif?imageMogr2/auto-orient/strip)\n![锦集.gif](https://upload-images.jianshu.io/upload_images/3333500-a935d0c0a257c0bf.gif?imageMogr2/auto-orient/strip)\n![圆.gif](https://upload-images.jianshu.io/upload_images/3333500-d7aed12dd5e9a248.gif?imageMogr2/auto-orient/strip)\n![抽屉效果.gif](https://upload-images.jianshu.io/upload_images/3333500-01d9e607ac5b81fc.gif?imageMogr2/auto-orient/strip)\n![AppstoreCard.gif](https://upload-images.jianshu.io/upload_images/3333500-ef510b6bbba569bc.gif?imageMogr2/auto-orient/strip)\n\n5. 使用步骤与举例 (更多使用见`UIViewController+Transitioning.h` 中的API 或 Demo)\n可以一步实现，也可以分步实现\n  a. 分步实现（建议使用，更灵活、多样化、统一化）：\n    1. 创建动画管理者\n    2. 设置动画时间\n    3. 设置手势使能\n```objc\n更多API的使用见demo\n\nTLSecondViewController *vc = [[TLSecondViewController alloc] init];\nvc.disableInteractivePopGestureRecognizer = YES; // 关闭手势\n\n// 1.创建动画管理者\nTLCATransitonAnimator *animator;\nanimator = [TLCATransitonAnimator animatorWithTransitionType:transitionType\n                                                   direction:direction\n                                     transitionTypeOfDismiss:transitionTypeOfDismiss\n                                          directionOfDismiss:dismissDirection];\nanimator.transitionDuration = 3.0; // 动画时间\n\n// 调用API转场\n// push（直接使用self发起API调用）\n[self pushViewController:vc animator:animator]; \n\n/** present\n[self presentViewController:vc animator:animator completion:^{\n        // 完成回调\n  }];\n*/\n```\nb. 一步实现：\n```objc\n更多API的使用见demo\n\nTLSecondViewController *vc = [[TLSecondViewController alloc] init];\n//  vc.disableInteractivePopGestureRecognizer = YES; // 关闭侧滑pop手势\n\n// push (直接使用self发起API调用）\n[self pushViewController: vc\nswipeType: TLSwipeTypeInAndOut\npushDirection: TLDirectionToRight\npopDirection: TLDirectionToRight];\n\n/** present\n[self presentViewController:vc\nswipeType: TLSwipeTypeInAndOut\npresentDirection:TLDirectionToRight\ndismissDirection:TLDirectionToRight\ncompletion:^ {\n// 完成回调\n}];\n*/\n```\n\n### 3. 特殊情况处理（如果您对以下问题其他好的的处理方法愿意分享，请通过发issue的方法告诉我）\n- 在push或pop时使用 `- hidesBottomBarWhenPushed`隐藏bottom bar 或 tabbar时，bar与view的转场动画不协调的情况（如下图所示）\n    - 问题由`happying`同学提出，并给出[他的处理方案](https://github.com/LoongerTao/TLTransitions/issues/7)\n    - 我的处理方法：在即将开始push时手动隐藏bar，pop完成后手动显示bar，以此取代 `toVC.hidesBottomBarWhenPushed = YES` 。（只在特殊情况下需要处理）\n```objc\n- (void)viewDidAppear:(BOOL)animated {\n    [super viewDidAppear:animated];\n\n    if (显示条件) {\n        self.tabBarController.tabBar.hidden = NO; // 如果是pop回来的，且需要显示bar，就手动将其显示\n    }\n}\n\n\n- (void)touchesBegan:(NSSet\u003cUITouch *\u003e *)touches withEvent:(UIEvent *)event {\n    UIViewController *toVc = [UIViewController new];\n    toVc.view.backgroundColor = [UIColor redColor];\n\n    toVc.hidesBottomBarWhenPushed = NO; // 设置为NO\n    self.tabBarController.tabBar.hidden = YES; // push前手动隐藏bar\n    \n    TLSwipeAnimator *anm = [TLSwipeAnimator animatorWithSwipeType:TLSwipeTypeInAndOut pushDirection:TLDirectionToTop popDirection:TLDirectionToBottom];\n    [self pushViewController:toVc animator:anm];\n}\n```\n    \n    \n![scene1.gif](https://upload-images.jianshu.io/upload_images/3333500-5399a99ad999dfe7.gif?imageMogr2/auto-orient/strip)\n\n\n\n### 4. 参考\n- [官方文档：关于模态转场、自定义动画、手势等（英文不好的，可以使用谷歌浏览器，能自动翻译）](https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html#//apple_ref/doc/uid/TP40007457-CH14-SW1)  \n- [部分动画效果来源](https://github.com/ColinEberhardt/VCTransitionsLibrary)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLoongerTao%2FTLTransitions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLoongerTao%2FTLTransitions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLoongerTao%2FTLTransitions/lists"}