美文网首页 ios零碎记录牛叉的demoiOS开发
DBPresentor -- 弹出视图管理器

DBPresentor -- 弹出视图管理器

作者: DreamBuddy | 来源:发表于2017-11-23 00:51 被阅读55次

深夜码字,这是第一个版本,后续进行更新
ViewController 以下简写为VC

平时所遇到的一些小困扰

  • 经常有需求要在页面上弹出一个框框,框框样式繁杂,我们通过自定义的View来解决问题,这个View为了出现时不那么突兀在显示时会用到一些简单顺眼的小动画~~
  • 系统的UIAlertView在iOS8以后不推荐使用了,Apple推荐UIAlertController来代替,但是UIAlertController在show的时候是以Modal方式被present出来的,首先需要找到一个VC来present,然后每个VC只能present一个VC,然后这就意味着当一个Alert存在时不允许弹出第二个(PS.臣妾实在是弹不出来啊)
  • 呈上所述的UIAlert***的UI可能设计师不太满意并要求开发者按照他的设计重新设计一款美其名曰CustomAlertView,What?Pardon?

陷入沉思

  • 遇到不同类型的弹窗如果只需要关注这个View的自定义,不需要关注这个View添加到哪里,不需要重复性的写动画,那么开发过程肯定会开心很多(PS.晚上可以早些回家打游戏/陪女友/XXX)
  • 自定义的AlertView竟然也只能弹一个,什么!!!每次弹还要找先一个VC??我不干,怎么破...

DBPresentor就是为此而生

  1. 再也不需要关注 动画
  2. 再也不需要关注 添加视图到哪里
  3. 再也不需要关注 谁来present AlertViewController
  4. 再也不需要关注 多个弹窗共同显示的逻辑处理

现在你只需要关注的是
如何实现UI图上那个自定义视图
剩下的事情交给DBPresentor

经过项目里的长期实战,Presentor已经添加了很多使用的动画,API经过精心调整使用起来更得心应手

/**
 默认使用API
 CustomView默认居中布局

 @param customView 自定义的View
 @param presentStyle 显示时的动画当时
 @param dismissStyle 隐藏时的动画方式
 @return ViewController实例
 */
+ (instancetype)makerWithCustomView:(UIView *)customView
                       presentStyle:(DBPresentorPresentStyle)presentStyle
                       dismissStyle:(DBPresentorDismissStyle)dismissStyle;

/**
 默认使用API
 CustomView自定义布局方式
 
 @param customView 自定义的View
 @param customLayout 布局回调,在这里尽兴CustomView的自定义布局
 @param presentStyle 显示时的动画当时
 @param dismissStyle 隐藏时的动画方式
 @return ViewController实例
 */
+ (instancetype)makerWithCustomView:(UIView *)customView
                       customLayout:(EXPresentorCustomLayoutBlock)customLayout
                       presentStyle:(DBPresentorPresentStyle)presentStyle
                       dismissStyle:(DBPresentorDismissStyle)dismissStyle;
/**
 Present时的动画Style
 */
typedef NS_ENUM(NSInteger, DBPresentorPresentStyle) {
    DBPresentorPresentStyleSystem,                                 // 系统样式
    DBPresentorPresentStyleFadeIn,                                 // 渐入
    DBPresentorPresentStyleBounce,                                 // 弹出
    DBPresentorPresentStyleExpandHorizontal,                       // 水平展开
    DBPresentorPresentStyleExpandVertical,                         // 垂直展开
    DBPresentorPresentStyleSlideDown,                              // 从上往下划入
    DBPresentorPresentStyleSlideUp,                                // 从下往上划入
    DBPresentorPresentStyleSlideLeft,                              // 从右往左划入
    DBPresentorPresentStyleSlideRight,                             // 从左往右划入
};

/**
 Dismiss时的动画Style
 */
typedef NS_ENUM(NSInteger,DBPresentorDismissStyle) {
    DBPresentorDismissStyleFadeOut,                                 // 渐出
    DBPresentorDismissStyleContractHorizontal,                      // 水平收起
    DBPresentorDismissStyleContractVertical,                        // 垂直收起
    DBPresentorDismissStyleSlideDown,                               // 向下划出
    DBPresentorDismissStyleSlideUp,                                 // 向上划出
    DBPresentorDismissStyleSlideLeft,                               // 向左划出
    DBPresentorDismissStyleSlideRight,                              // 向右划出
};
/**
 弹出VC 默认方式 后弹出的会遮挡前一个
 */
- (void)show;

/**
 弹出VC 可选择动画开关

 @param animated 是否启用动画
 */
- (void)show:(BOOL)animated;

/**
 弹出VC 可选择动画开关 带显示完成的Block

 @param animated 是否启用动画
 @param completion 显示完成的Block
 */
- (void)show:(BOOL)animated completion:(void (^)(void))completion;

/**
 弹出VC 可选择动画开关 带显示完成的Block 可选弹窗的弹出等级

 @param animated 是否启用动画
 @param windowLevel 弹出等级 UIWindowLevel
 @param completion 显示完成的Block
 */
- (void)show:(BOOL)animated windowLevel:(UIWindowLevel)windowLevel completion:(void (^)(void))completion;

留图不留种....
我当然留 Duang Duang Duang
Github Source Code 链接

相关文章

  • DBPresentor -- 弹出视图管理器

    深夜码字,这是第一个版本,后续进行更新ViewController 以下简写为VC 平时所遇到的一些小困扰 经常有...

  • 自定义弹出视图

    强大,易用,高扩展的提醒视图,弹出视图 操作性弹出视图 推荐TYAlertController 强大,易用,高...

  • iOS-弹出视图或者限制时间消失

    一.弹出视图

  • Position fixed Inner content lis

    在做项目的过程中,总是会遇到要实现一个弹出视图,多数需求都是在弹出视图中添加一个滚动列表,使弹出视图撑满整个屏幕,...

  • iOS 自定义弹框

    一个可以自定义弹出视图内容,弹出视图所在位置的小轮子。 使用:

  • iOS7、8半透明弹出框及弹出后弹出前页面消失问题

    需求:做一个自定义视图弹框,弹出框之外的背景视图为半透明设计方案:使用模态视图弹出自定义视图产生问题:presen...

  • popover弹出视图

    UIPopoverController 在iOS9被废弃了。 实现代理方法

  • 弹出视图封装

    大家都知道苹果自带的弹框有三种,但是你会发现在项目的开发中,这些是远远不够的,下面给大家介绍一下封装的弹款,用的地...

  • Android 上拉菜单

    Android 上拉菜单 Dialog 会置于顶层,项目需求是这样的: 要求点击购物车,弹出后面的视图,弹出的视图...

  • 【转载】iOS 模态视图

    iOS 模态视图 概念: ios开发中,在当前视图上再弹出一个视图(模态视图)例如登陆视图,分享视图,注册等等。 ...

网友评论

    本文标题:DBPresentor -- 弹出视图管理器

    本文链接:https://www.haomeiwen.com/subject/snsavxtx.html