XToast
描述
XToast 是基于 https://github.com/scalessec/Toast 的 4.0.0 版本进行调整和封装。
根据项目的实际需求,封装了以下功能:
功能
- 支持在
View
或Window
上显示,使用默认的配置信息。 - 添加超时自动消失的
Loading View
,支持添加短文。 - 添加
Loading View
的遮罩层,阻止页面用户交互。 Toast
和Loading
方法都在主线程执行,避免UI线程问题。
Toast库的调整
Toast
添加makeToastActivity: withText:
方法,为Activity
添加短文。Toast
添加Activity
的遮罩层,可以设置setCoverEnabled
是否阻止用户交互事件。Toast
添加类名及方法名前缀,避免重名问题。
示例
要运行示例项目,首先克隆存储库,然后从 Example 目录运行 pod install
。
安装
XToast 可以通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中
pod 'XToast', '~> 0.3.1'
用法
步骤 1
#import <XToast/XToast.h>
步骤 2
// Show in the window
+ (void)showToastWithText:(NSString *)text;
+ (void)hideToast;
+ (void)showLoading;
+ (void)showLoadingAndHideAfter:(NSTimeInterval)interval;
+ (void)showLoadingWithText:(NSString *)text;
+ (void)showLoadingWithText:(NSString *)text hideAfter:(NSTimeInterval)interval;
+ (void)hideLoading;
// Show in the view
+ (void)showToastWithText:(NSString *)text inView:(UIView *)view;
+ (void)hideToastInView:(UIView *)view;
+ (void)showLoadingInView:(UIView *)view;
+ (void)showLoadingInView:(UIView *)view hideAfter:(NSTimeInterval)interval;
+ (void)showLoadingWithText:(NSString *)text inView:(UIView *)view;
+ (void)showLoadingWithText:(NSString *)text inView:(UIView *)view hideAfter:(NSTimeInterval)interval;
+ (void)hideLoadingInView:(UIView *)view;
// You can set the "XCSToastManager" to customize it if you needed, use by #import <XToast/UIView+XToast.h>
作者
许可协议
XToast 可在 MIT 许可协议下获得。有关更多信息,请参阅 LICENSE 文件。