首页 技术 正文
技术 2022年11月14日
0 收藏 373 点赞 2,383 浏览 10241 个字

demo 来源: https://github.com/jdg/MBProgressHUD/

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px “PingFang SC”; color: #1d9421 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1d9421 }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3c828c }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px }
p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #3d1d81 }
p.p7 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #c91b13 }
p.p8 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #31595d }
p.p9 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #294c50 }
p.p10 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #822e0e }
p.p11 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #6122ae }
p.p12 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #703daa }
p.p13 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #539aa4 }
span.s1 { font: 18.0px Menlo }
span.s2 { }
span.s3 { color: #c32275 }
span.s4 { color: #000000 }
span.s5 { color: #294c50 }
span.s6 { color: #703daa }
span.s7 { color: #0435ff }
span.s8 { color: #539aa4 }
span.s9 { color: #78492a }
span.s10 { font: 18.0px “PingFang SC” }
span.s11 { color: #6122ae }
span.s12 { color: #c91b13 }
span.s13 { color: #3d1d81 }
span.s14 { font: 18.0px “PingFang SC”; color: #c91b13 }
span.s15 { color: #1d9421 }
span.s16 { font: 18.0px “PingFang SC”; color: #1d9421 }
span.Apple-tab-span { white-space: pre }

//只有小菊花

– (void)indeterminateExample {

// Show the HUD on the root view (self.view is a scrollable table view and thus not suitable,

// as the HUD would move with the content as we scroll).

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Fire off an asynchronous task, giving UIKit the opportunity to redraw wit the HUD added to the

// view hierarchy.

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background

[self doSomeWork];

// IMPORTANT – Dispatch back to the main thread. Always access UI

// classes (including MBProgressHUD) on the main thread.

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//小菊花+文字

– (void)labelExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the label text.

hud.label.text = NSLocalizedString(@”Loading…”, @”HUD loading title”);

// You can also adjust other label properties if needed.

// hud.label.font = [UIFont italicSystemFontOfSize:16.f];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//小菊花+文字+detailsLabel

– (void)detailsLabelExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the label text.

hud.label.text = NSLocalizedString(@”Loading…”, @”HUD loading title”);

// Set the details label text. Let’s make it multiline this time.

hud.detailsLabel.text = NSLocalizedString(@”Parsing data\n(1/1)”, @”HUD title”);

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

– (void)windowExample {

// Covers the entire screen. Similar to using the root view controller view.

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//圆环进度条+文字

– (void)determinateExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the determinate mode to show task progress.

hud.mode = MBProgressHUDModeDeterminate;

hud.label.text = NSLocalizedString(@”Loading…”, @”HUD loading title”);

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//圆环进度条+文字+ 取消按钮

– (void)determinateNSProgressExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the determinate mode to show task progress.

hud.mode = MBProgressHUDModeDeterminate;

hud.label.text = NSLocalizedString(@”Loading…”, @”HUD loading title”);

// Set up NSProgress

NSProgress *progressObject = [NSProgress progressWithTotalUnitCount:100];

hud.progressObject = progressObject;

// Configure a cancel button.

[hud.button setTitle:NSLocalizedString(@”Cancel”, @”HUD cancel button title”) forState:UIControlStateNormal];

[hud.button addTarget:progressObject action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgressObject:progressObject];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//圆环进度条+文字

– (void)annularDeterminateExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the annular determinate mode to show task progress.

hud.mode = MBProgressHUDModeAnnularDeterminate;

hud.label.text = NSLocalizedString(@”Loading…”, @”HUD loading title”);

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//直线进度条+文字

– (void)barDeterminateExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the bar determinate mode to show task progress.

hud.mode = MBProgressHUDModeDeterminateHorizontalBar;

hud.label.text = NSLocalizedString(@”Loading…”, @”HUD loading title”);

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

#pragma mark –自定义视图

//自定义视图

– (void)customViewExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the custom view mode to show any view.

hud.mode = MBProgressHUDModeCustomView;

// Set an image view with a checkmark.

//default

//    UIImage *image = [[UIImage imageNamed:@”Checkmark”] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];

//mxs

//UIImage *image = [[UIImage imageNamed:@”下拉刷新一80×80″] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];//success  下拉刷新一80×80 密码登录lgo

UIImage *image = [UIImage imageNamed:@”下拉刷新一80×80″];//success  下拉刷新一80×80 密码登录lgo

UIImageView *imgV = [[UIImageView alloc] initWithImage:image];

[imgV.layer addAnimation:[self makeRotation] forKey:nil];

hud.customView = imgV;

// Looks a bit nicer if we make it square.

hud.square = YES;

// Optional label text.

hud.label.text = @”Done”;

[hud hideAnimated:YES afterDelay:2.f];//几秒后消失

}

#pragma mark –旋转

– (CABasicAnimation *)makeRotation{

CATransform3D rotationTransform = CATransform3DMakeRotation((360*180.0)/(M_PI), 0, 0, -1);

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@”transform”];

animation.toValue = [NSValue valueWithCATransform3D:rotationTransform];

animation.duration  =  1;

animation.autoreverses = NO;

animation.cumulative = YES;

animation.fillMode = kCAFillModeForwards;

animation.repeatCount = 100;

return animation;

}

//只有文字

– (void)textExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the text mode to show only text.

hud.mode = MBProgressHUDModeText;

hud.label.text = NSLocalizedString(@”Message here!”, @”HUD message title”);

// Move to bottm center.

hud.offset = CGPointMake(0.f, MBProgressMaxOffset);

[hud hideAnimated:YES afterDelay:3.f];

}

– (void)cancelationExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set the determinate mode to show task progress.

hud.mode = MBProgressHUDModeDeterminate;

hud.label.text = NSLocalizedString(@”Loading…”, @”HUD loading title”);

// Configure the button.

[hud.button setTitle:NSLocalizedString(@”Cancel”, @”HUD cancel button title”) forState:UIControlStateNormal];

[hud.button addTarget:self action:@selector(cancelWork:) forControlEvents:UIControlEventTouchUpInside];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

//小菊花–转换–>圆环

– (void)modeSwitchingExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set some text to show the initial status.

hud.label.text = NSLocalizedString(@”Preparing…”, @”HUD preparing title”);

// Will look best, if we set a minimum size.

hud.minSize = CGSizeMake(150.f, 100.f);

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

// Do something useful in the background and update the HUD periodically.

[self doSomeWorkWithMixedProgress];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

– (void)networkingExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Set some text to show the initial status.

hud.label.text = NSLocalizedString(@”Preparing…”, @”HUD preparing title”);

// Will look best, if we set a minimum size.

hud.minSize = CGSizeMake(150.f, 100.f);

[self doSomeNetworkWorkWithProgress];

}

– (void)dimBackgroundExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

// Change the background view style and color.

hud.backgroundView.style = MBProgressHUDBackgroundStyleSolidColor;

hud.backgroundView.color = [UIColor colorWithWhite:0.f alpha:0.1f];

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

– (void)colorExample {

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];

hud.contentColor = [UIColor colorWithRed:0.f green:0.6f blue:0.7f alpha:1.f];

// Set the label text.

hud.label.text = NSLocalizedString(@”Loading…”, @”HUD loading title”);

dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0), ^{

[self doSomeWork];

dispatch_async(dispatch_get_main_queue(), ^{

[hud hideAnimated:YES];

});

});

}

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #822e0e }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; min-height: 21.0px }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #1d9421 }
span.s1 { }
span.s2 { color: #c32275 }
span.s3 { color: #000000 }
span.s4 { color: #3d1d81 }
span.s5 { color: #0435ff }

#pragma mark – Tasks

– (void)doSomeWork {

// Simulate by just waiting.

sleep(3.);

}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,954
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,479
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,291
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,108
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,740
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,774