IOS第三方之SVProgressHUD

简介:

这个第三方和MBProgressHUD差不多,也挺简单的。


//
//  ViewController.m
//  ProgressHUD
//
//  Created by City--Online on 15/6/15.
//  Copyright (c) 2015年 City--Online. All rights reserved.
//

#import "ViewController.h"
#import "SVProgressHUD.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(handleNotification:)
                                                 name:SVProgressHUDWillAppearNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(handleNotification:)
                                                 name:SVProgressHUDDidAppearNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(handleNotification:)
                                                 name:SVProgressHUDWillDisappearNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(handleNotification:)
                                                 name:SVProgressHUDDidDisappearNotification
                                               object:nil];
}
- (void)handleNotification:(NSNotification *)notif
{
    NSLog(@"Notification recieved: %@", notif.name);
    NSLog(@"Status user info key: %@", [notif.userInfo objectForKey:SVProgressHUDStatusUserInfoKey]);
}


- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
    [btn setTitle:@"提示框" forState:UIControlStateNormal];
    btn.frame=CGRectMake(20, 100, 100, 100);
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}
-(void)btnClick:(id)sender
{
    
//    [SVProgressHUD showWithStatus:@"Loading"];

//    [SVProgressHUD show];
//    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//        sleep(3);
//        dispatch_async(dispatch_get_main_queue(), ^{
//            [SVProgressHUD dismiss];
//        });
//    });
    
//    [self showWithProgress];
    
    [self showSuccess];
}
static float progress = 0.0f;
- (void)showWithProgress {
    progress = 0.0f;
    [SVProgressHUD showProgress:0 status:@"Loading"];
    [self performSelector:@selector(increaseProgress) withObject:nil afterDelay:0.3f];
}

- (void)increaseProgress {
    progress+=0.1f;
    [SVProgressHUD showProgress:progress status:@"Loading"];
    
    if(progress < 1.0f)
        [self performSelector:@selector(increaseProgress) withObject:nil afterDelay:0.3f];
    else
        [self performSelector:@selector(dismiss) withObject:nil afterDelay:0.4f];
}
- (void)dismiss {
    [SVProgressHUD dismiss];
}

- (void)showInfo{
    [SVProgressHUD showInfoWithStatus:@"Useful Information."];
}

- (void)showSuccess {
    [SVProgressHUD showSuccessWithStatus:@"Great Success!"];
}

- (void)showError {
    [SVProgressHUD showErrorWithStatus:@"Failed with Error"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end





相关文章
|
9月前
|
iOS开发
iOS开发中使用第三方静态字体
iOS开发中使用第三方静态字体
|
6月前
|
数据安全/隐私保护 Android开发 iOS开发
解决第三方邮箱APP登陆QQ、163邮箱无法验证账户名或密码的问题(IOS、MacOS、Windows、Android)
解决第三方邮箱APP登陆QQ、163邮箱无法验证账户名或密码的问题(IOS、MacOS、Windows、Android)
109 0
|
8月前
|
iOS开发
iOS 第三方dSYM定位BUG
iOS 第三方dSYM定位BUG
92 0
|
iOS开发
imazing2023许可证码第三方iOS设备管理软件
iMazing是一款iPhone备份软件,使用iMazing几乎可以备份iPhone的全部数据,不仅包括照片、视频,还包括短信、通讯录,APP数据等。
916 1
imazing2023许可证码第三方iOS设备管理软件
|
缓存 iOS开发
iOS第三方文件压缩框架——Godzippa
iOS第三方文件压缩框架——Godzippa
364 0
|
监控 开发者 iOS开发
iOS第三方网络诊断库——LDNetDiagnoService
iOS第三方网络诊断库——LDNetDiagnoService
490 0
|
开发者 iOS开发
iOS第三方星级视图控件——HCSStarRatingView
iOS第三方星级视图控件——HCSStarRatingView
140 0
|
iOS开发
iOS第三方左对齐布局类——UICollectionViewLeftAlignedLayout
iOS第三方左对齐布局类——UICollectionViewLeftAlignedLayout
415 0
|
iOS开发
iOS中第三方有序字典框架——M13OrderedDictionary(二)
iOS中第三方有序字典框架——M13OrderedDictionary
365 0