myQRCodeGit 0.0.1

myQRCodeGit 0.0.1

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released最新版本2016年11月

linwf 维护。



  • 作者:
  • 郑凯中

SVProgressHUD

Pod Version Pod License Pod Platform Carthage compatible

SVProgressHUD 是一个干净易用的 HUD,用于在 iOS 和 tvOS 上显示任务进度。

SVProgressHUD

演示

Appetize.io 上尝试 SVProgressHUD

安装

从 CocoaPods 安装

CocoaPods 是 Objective-C 的依赖管理器,它可以自动化并简化使用第三方库(如 SVProgressHUD)的过程。首先,将以下行添加到您的 Podfile

pod 'SVProgressHUD'

如果您想使用 SVProgressHUD 的最新功能,请使用外部的源依赖项。

pod 'SVProgressHUD', :git => 'https://github.com/SVProgressHUD/SVProgressHUD.git'

这将直接从 master 分支中拉取。我们通常会小心地将内容推送到那里,这是我们自己在所有项目中使用的版本。

其次,将 SVProgressHUD 安装到您的项目中

pod install

Carthage

Carthage 是一个去中心化的依赖管理器,它会构建您的依赖并提供二进制框架。

您可以使用以下命令通过 Homebrew 安装 Carthage

$ brew update
$ brew install carthage

要使用 Carthage 将 SVProgressHUD 集成到您的 Xcode 项目中,请在您的 Cartfile 中指定它

github "SVProgressHUD/SVProgressHUD"

运行 carthage update 构建框架,然后将构建的 SVProgressHUD.framework(位于 Carthage/Build/iOS 文件夹中)拖放到您的 Xcode 项目中(在 TargetsLinked Frameworks and Libraries 中)。

手动

  • SVProgressHUD/SVProgressHUD 文件夹拖放到您的项目中。
  • 请确保将 SVProgressHUD.bundle 添加到 Targets->Build Phases->Copy Bundle Resources
  • QuartzCore 框架添加到您的项目中。

使用方法

(请参考 /Demo 中的示例 Xcode 项目)

SVProgressHUD 作为单例创建(即不需要显式分配和初始化;您直接调用 [SVProgressHUD method])。

明智地使用 SVProgressHUD!只有当您绝对需要在用户前进之前执行一项任务时才使用它。不良的使用示例:下拉刷新、无限滚动、发送消息。

在您的应用中使用 SVProgressHUD 通常看起来就像这样(使用 Grand Central Dispatch)

[SVProgressHUD show];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    // time-consuming task
    dispatch_async(dispatch_get_main_queue(), ^{
        [SVProgressHUD dismiss];
    });
});

显示HUD

您可以使用以下任一方法显示未确定任务的进度

+ (void)show;
+ (void)showWithStatus:(NSString*)string;

如果您希望HUD反映任务进度,请使用以下任一方法

+ (void)showProgress:(CGFloat)progress;
+ (void)showProgress:(CGFloat)progress status:(NSString*)status;

隐藏HUD

可以通过以下方式隐藏HUD

+ (void)dismiss;
+ (void)dismissWithDelay:(NSTimeInterval)delay;

如果您想堆叠HUD,可以使用

+ (void)popActivity;

当popActivity调用次数与show调用次数相匹配时,HUD将被隐藏

或显示确认图案,然后稍微延迟消失。显示时间取决于minimumDismissTimeInterval和给定字符串的长度。

+ (void)showInfoWithStatus:(NSString*)string;
+ (void)showSuccessWithStatus:(NSString*)string;
+ (void)showErrorWithStatus:(NSString*)string;
+ (void)showImage:(UIImage*)image status:(NSString*)string;

定制化

SVProgressHUD可以通过以下方法进行定制化

+ (void)setDefaultStyle:(SVProgressHUDStyle)style;                  // default is SVProgressHUDStyleLight
+ (void)setDefaultMaskType:(SVProgressHUDMaskType)maskType;         // default is SVProgressHUDMaskTypeNone
+ (void)setDefaultAnimationType:(SVProgressHUDAnimationType)type;   // default is SVProgressHUDAnimationTypeFlat
+ (void)setMinimumSize:(CGSize)minimumSize;                         // default is CGSizeZero, can be used to avoid resizing for a larger message
+ (void)setRingThickness:(CGFloat)width;                            // default is 2 pt
+ (void)setRingRadius:(CGFloat)radius;                              // default is 18 pt
+ (void)setRingNoTextRadius:(CGFloat)radius;                        // default is 24 pt
+ (void)setCornerRadius:(CGFloat)cornerRadius;                      // default is 14 pt
+ (void)setFont:(UIFont*)font;                                      // default is [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]
+ (void)setForegroundColor:(UIColor*)color;                         // default is [UIColor blackColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundColor:(UIColor*)color;                         // default is [UIColor whiteColor], only used for SVProgressHUDStyleCustom
+ (void)setBackgroundLayerColor:(UIColor*)color;                    // default is [UIColor colorWithWhite:0 alpha:0.4], only used for SVProgressHUDMaskTypeCustom
+ (void)setInfoImage:(UIImage*)image;                               // default is the bundled info image provided by Freepik
+ (void)setSuccessImage:(UIImage*)image;                            // default is bundled success image from Freepik
+ (void)setErrorImage:(UIImage*)image;                              // default is bundled error image from Freepik
+ (void)setViewForExtension:(UIView*)view;                          // default is nil, only used if #define SV_APP_EXTENSIONS is set
+ (void)setMinimumDismissTimeInterval:(NSTimeInterval)interval;     // default is 5.0 seconds
+ (void)setFadeInAnimationDuration:(NSTimeInterval)duration;        // default is 0.15 seconds
+ (void)setFadeOutAnimationDuration:(NSTimeInterval)duration;       // default is 0.15 seconds

此外,SVProgressHUD支持大部分上述方法的UIAppearance协议。

提示

作为标准,SVProgressHUD提供两种预配置的样式

  • SVProgressHUDStyleLight:白色背景,黑色旋转器和文本
  • SVProgressHUDStyleDark:黑色背景,白色旋转器和文本

如果您想使用自定义颜色并使用setForegroundColorsetBackgroundColor:,请记得通过setDefaultStyle:设置SVProgressHUDStyleCustom

通知

SVProgressHUD在显示/隐藏时通过 NSNotificationCenter 发布四个通知

  • SVProgressHUDWillAppearNotification 当显示动画开始时
  • SVProgressHUDDidAppearNotification 当显示动画完成后
  • SVProgressHUDWillDisappearNotification 当隐藏动画开始时
  • SVProgressHUDDidDisappearNotification 当隐藏动画完成后

每个通知包含一个包含HUD状态字符串的用户信息字典(如果有,可通过SVProgressHUDStatusUserInfoKey检索)。

此外,SVProgressHUD在用户触摸全屏幕时发布SVProgressHUDDidReceiveTouchEventNotification通知,或当用户直接触摸HUD时发布SVProgressHUDDidTouchDownInsideNotification通知。对于这些通知,不传递userInfo,但对象参数包含相关的UIEvent

应用扩展

在App扩展中使用SVProgressHUD时,请设置#define SV_APP_EXTENSIONS以避免使用不可用的API。另外,从您的扩展视图控制器调用setViewForExtension:使用self.view

为此项目做出贡献

如果您有功能请求或错误报告,请通过发送pull请求或通过创建新问题来帮忙。请花些时间阅读Nicolas Gallagher编写的指南

许可

SVProgressHUD根据MIT许可证的条款和条件进行分发。成功、错误和信息图标由FreepikFlaticon创建,并受创意共享BY 3.0许可。

致谢

SVProgressHUDSam VermetteTobias Tiemerding项目贡献者 提供。如果您在您的项目中使用了 SVProgressHUD,作者的署名将非常感激。