MBProgressHUD(0.9.1)详解总结
2016-02-29 15:16
246 查看
参考文档:
原博客
github源码
类似库:SVProgressHUD
二、组成(4部分)
1、背景
// 背景框的透明度,默认值是0.8
@property (assign) float opacity;
// 背景框的颜色
// 需要注意的是如果设置了这个属性,则opacity属性会失效,即不会有半透明效果
@property (MB_STRONG) UIColor *color;
// 背景框的圆角半径。默认值是10.0
@property (assign) float cornerRadius;
2、动画
// 菊花的颜色,默认是白色
@property (MB_STRONG) UIColor *activityIndicatorColor;
3、标题
// 标题文本的字体及颜色
@property (MB_STRONG) UIFont* labelFont;
@property (MB_STRONG) UIColor* labelColor;
4、详情
// 详情文本的字体及颜色
@property (MB_STRONG) UIFont* detailsLabelFont;
@property (MB_STRONG) UIColor* detailsLabelColor;
三、补充
//整个窗口使用渐变色(色值是写死的,不能修改)
@property (assign) BOOL dimBackground;
1、- (id)initWithWindow:(UIWindow *)window;
2、- (id)initWithView:(UIView *)view;
注:这里的 window 和 view 只用来设置 HUD 的 frame,添加到视图上还是要我们手动添加。
二、布局设置
// HUD相对于父视图中心点的x轴偏移量和y轴偏移量
@property (assign) float xOffset;
@property (assign) float yOffset;
// HUD各元素与HUD边缘的间距
@property (assign) float margin;
// HUD背景框的最小大小
@property (assign) CGSize minSize;
// HUD的实际大小
@property (atomic, assign, readonly) CGSize size;
// 是否强制HUD背景框宽高相等
@property (assign, getter = isSquare) BOOL square;
注:HUD 填满父控件,屏蔽父控件的所有操作。
三、属性设置
1、mode设置
2、隐藏与显示有关的属性
// HUD显示和隐藏的动画类型
@property (assign) MBProgressHUDAnimation animationType;
// HUD显示的最短时间。设置这个值是为了避免HUD显示后立即被隐藏。默认值为0
@property (assign) float minShowTime;
// 这个属性设置了一个宽限期,它是在没有显示HUD窗口前被调用方法可能运行的时间。
// 如果被调用方法在宽限期内执行完,则HUD不会被显示。
// 这主要是为了避免在执行很短的任务时,去显示一个HUD窗口。
// 默认值是0。只有当任务状态是已知时,才支持宽限期。具体我们看实现代码。
@property (assign) float graceTime;
// 这是一个标识位,标明执行的操作正在处理中。这个属性是配合graceTime使用的。
// 如果没有设置graceTime,则这个标识是没有太大意义的。在使用showWhileExecuting:onTarget:withObject:animated:方法时,
// 会自动去设置这个属性为YES,其它情况下都需要我们自己手动设置。
@property (assign) BOOL taskInProgress;
// 隐藏时是否将HUD从父视图中移除,默认是NO。
@property (assign) BOOL removeFromSuperViewOnHide;
// 进度指示器,从0.0到1.0,默认值为0.0
@property (assign) float progress;
// 在HUD被隐藏后的回调
@property (copy) MBProgressHUDCompletionBlock completionBlock;
四、方法
1、显示与隐藏有关的方法
//执行后台任务时显示 HUD,后台任务完成后隐藏 HUD
- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated;
//基于 GCD 的调用,显示 HUD,任务完成之后执行 completion,最后隐藏 HUD
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue
completionBlock:(MBProgressHUDCompletionBlock)completion;
//隐藏
- (void)hide:(BOOL)animated;
//
- (void)hide:(BOOL)animated afterDelay:
+ (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated
+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated
+ (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated
五、代理(MBProgressHUDDelegate)
//在 HUD 隐藏后调用
- (void)hudWasHidden:(MBProgressHUD *)hud;
原博客
github源码
类似库:SVProgressHUD
详细介绍
一、样式(枚举 MBProgressHUDMode)mode | 备注 |
---|---|
MBProgressHUDModeIndeterminate | 默认, UIActivityIndicatorView(菊花) |
MBProgressHUDModeDeterminate | 圆饼图 |
MBProgressHUDModeDeterminateHorizontalBar | 水平进度条 |
MBProgressHUDModeAnnularDeterminate | 圆环 |
MBProgressHUDModeCustomView | 自定义视图 |
MBProgressHUDModeText | 文本 |
1、背景
// 背景框的透明度,默认值是0.8
@property (assign) float opacity;
// 背景框的颜色
// 需要注意的是如果设置了这个属性,则opacity属性会失效,即不会有半透明效果
@property (MB_STRONG) UIColor *color;
// 背景框的圆角半径。默认值是10.0
@property (assign) float cornerRadius;
2、动画
// 菊花的颜色,默认是白色
@property (MB_STRONG) UIColor *activityIndicatorColor;
3、标题
// 标题文本的字体及颜色
@property (MB_STRONG) UIFont* labelFont;
@property (MB_STRONG) UIColor* labelColor;
4、详情
// 详情文本的字体及颜色
@property (MB_STRONG) UIFont* detailsLabelFont;
@property (MB_STRONG) UIColor* detailsLabelColor;
三、补充
//整个窗口使用渐变色(色值是写死的,不能修改)
@property (assign) BOOL dimBackground;
使用
一、初始化1、- (id)initWithWindow:(UIWindow *)window;
2、- (id)initWithView:(UIView *)view;
注:这里的 window 和 view 只用来设置 HUD 的 frame,添加到视图上还是要我们手动添加。
二、布局设置
// HUD相对于父视图中心点的x轴偏移量和y轴偏移量
@property (assign) float xOffset;
@property (assign) float yOffset;
// HUD各元素与HUD边缘的间距
@property (assign) float margin;
// HUD背景框的最小大小
@property (assign) CGSize minSize;
// HUD的实际大小
@property (atomic, assign, readonly) CGSize size;
// 是否强制HUD背景框宽高相等
@property (assign, getter = isSquare) BOOL square;
注:HUD 填满父控件,屏蔽父控件的所有操作。
三、属性设置
1、mode设置
2、隐藏与显示有关的属性
// HUD显示和隐藏的动画类型
@property (assign) MBProgressHUDAnimation animationType;
// HUD显示的最短时间。设置这个值是为了避免HUD显示后立即被隐藏。默认值为0
@property (assign) float minShowTime;
// 这个属性设置了一个宽限期,它是在没有显示HUD窗口前被调用方法可能运行的时间。
// 如果被调用方法在宽限期内执行完,则HUD不会被显示。
// 这主要是为了避免在执行很短的任务时,去显示一个HUD窗口。
// 默认值是0。只有当任务状态是已知时,才支持宽限期。具体我们看实现代码。
@property (assign) float graceTime;
// 这是一个标识位,标明执行的操作正在处理中。这个属性是配合graceTime使用的。
// 如果没有设置graceTime,则这个标识是没有太大意义的。在使用showWhileExecuting:onTarget:withObject:animated:方法时,
// 会自动去设置这个属性为YES,其它情况下都需要我们自己手动设置。
@property (assign) BOOL taskInProgress;
// 隐藏时是否将HUD从父视图中移除,默认是NO。
@property (assign) BOOL removeFromSuperViewOnHide;
// 进度指示器,从0.0到1.0,默认值为0.0
@property (assign) float progress;
// 在HUD被隐藏后的回调
@property (copy) MBProgressHUDCompletionBlock completionBlock;
四、方法
1、显示与隐藏有关的方法
//执行后台任务时显示 HUD,后台任务完成后隐藏 HUD
- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated;
//基于 GCD 的调用,显示 HUD,任务完成之后执行 completion,最后隐藏 HUD
- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue
completionBlock:(MBProgressHUDCompletionBlock)completion;
//隐藏
- (void)hide:(BOOL)animated;
//
- (void)hide:(BOOL)animated afterDelay:
+ (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated
+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated
+ (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated
五、代理(MBProgressHUDDelegate)
//在 HUD 隐藏后调用
- (void)hudWasHidden:(MBProgressHUD *)hud;
相关文章推荐
- Leetcode 310. Minimun Height Trees使用set快速删除元素
- 带有指示器的自定义底部导航栏的实现
- linux syslog详解
- UVA 133(82)----The Dole Queue
- leetcode 202. Happy Number
- H5单页面架构:自定义路由 + requirejs + zepto + underscore
- LeetCode Copy List with Random Pointer
- 《JAVA与模式》学习之装饰模式
- UIKit框架(12)控制器view的生命周期方法
- Linux分区
- 关于屏幕常亮的问题
- android电池充电以及电量检测驱动分析
- 5分钟弄懂Docker!
- JSON入门
- 第七天
- Android控件— — —ImageView
- transmission简单使用
- map容器的插入(伪复制)遇到的默认构造问题
- 驱动安装注册表指令
- spring-jms的applicationContext.xml