WSProgressHUD
这是一个用于 iPhone 和 iPad 的美丽 HUD 视图
用法
下载项目,在演示目录中运行 WSProgressHUD.xcodeproj。
[WSProgressHUD show];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
...
dispatch_async(dispatch_get_main_queue(), ^{
...
[WSProgressHUD dismiss];
});
});
//Show on the self.view
@implementation ViewController
{
WSProgressHUD *hud;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Add HUD to view
hud = [[WSProgressHUD alloc] initWithView:self.navigationController.view];
[self.view addSubview:hud];
//show
[hud showWithString:@"Wating..." maskType:WSProgressHUDMaskTypeBlack];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[hud dismiss];
});
}
//Show on the window
//show
[WSProgressHUD show];
//Show with mask
[WSProgressHUD showWithMaskType:WSProgressHUDMaskTypeBlack];
//Show with mask without tabbar
[WSProgressHUD showWithStatus:@"Loading..." maskType:WSProgressHUDMaskTypeBlack maskWithout:WSProgressHUDMaskWithoutTabbar];
//Show with string
[WSProgressHUD showWithStatus:@"Loading..."];
//Show with facebook shimmering
[WSProgressHUD showShimmeringString:@"WSProgressHUD Loading..."];
//Show with Progress
[WSProgressHUD showProgress:progress status:@"Updating..."];
//Show with image
[WSProgressHUD showSuccessWithStatus:@"Thanks.."];
//Show with string
[WSProgressHUD showImage:nil status:@"WSProgressHUD"]
//Dismiss
[WSProgressHUD dismiss];
//And There have 3 indicator style for your choice
[WSProgressHUD setProgressHUDIndicatorStyle:WSProgressHUDIndicatorSmall] //small custom spinner
安装
CocoaPods
WSProgressHUD 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'WSProgressHUD'
Carthage
Carthage 是一个去中心化的依赖管理器,它能构建你的依赖并提供二进制框架。要使用 Carthage 将 WSProgressHUD
集成到你的 Xcode 项目中,请在你的 Cartfile
中指定它。
github "devSC/WSProgressHUD"
运行 carthage update
构建框架,并将构建好的 WSProgressHUD.framework
(在 Carthage/Build/iOS 文件夹中)拖入你的 Xcode 项目(在 Targets
的“链接框架和库”中)。
手动方式
将 WSProgressHUD/Demo/WSProgressHUD
文件夹拖入你的项目。然后确保 WSProgressHUD.bundle
已添加到 Targets -> Build Phases -> Copy Bundle Resources。将 QuartzCore 框架添加到你的项目中。
Swift
尽管 WSProgressHUD
使用 Objective-C 编写,但它可以在 Swift 中无任何困难地使用。如果你使用 CocoaPods,请将以下行添加到你的 Podfile
use_frameworks!
如果你手动添加了 WSProgressHUD
,只需将包含 WSProgressHUD
头文件的 桥接头文件 添加到你的项目中。
感谢
@Shimmering @SVProgressHUD @MMMaterialDesignSpinner
作者
Wilson-Yuan, [email protected]
许可证
WSProgressHUD 可在 MIT 许可证下使用。有关更多信息,请参阅 LICENSE 文件。