博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS第三方之SVProgressHUD
阅读量:5786 次
发布时间:2019-06-18

本文共 3411 字,大约阅读时间需要 11 分钟。

这个第三方和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

转载地址:http://ayxyx.baihongyu.com/

你可能感兴趣的文章
威胁快报|ProtonMiner挖矿蠕虫扩大攻击面,加速传播
查看>>
PAT A1116
查看>>
App上架/更新怕被拒? iOS过审“避雷秘籍”请查收
查看>>
CentOS 7 防火墙操作
查看>>
关于 top 工具的 6 个替代方案
查看>>
程序员最讨厌的9句话,你可有补充?
查看>>
PAT A1037
查看>>
浅谈RPC
查看>>
HDU 4422 The Little Girl who Picks Mushrooms(简单题)
查看>>
HDUOJ---------(1045)Fire Net
查看>>
TextView 超链接点击跳转到下一个Activity
查看>>
Java技术专题之JVM逻辑内存回收机制研究图解版
查看>>
mysql经常使用命令
查看>>
sql server 2008安装的时候选NT AUTHORITY\NEWORK SERVICE 还是选 NT AUTHORITY\SYSTEM ?
查看>>
UNIX环境高级编程之第4章:文件和文件夹-习题
查看>>
bzoj2843极地旅行社题解
查看>>
【Linux】Linux中常用操作命令
查看>>
MyBatis3-SqlSessionDaoSupport的使用
查看>>
ReactiveSwift源码解析(三) Signal代码的基本实现
查看>>
MVC模式利用xib文件定制collectionCell
查看>>