使用UIActivityIndicatorView
来源:互联网 发布:佛山市2015年经济数据 编辑:程序博客网 时间:2024/05/17 19:18
你需要在屏幕上将该指示器居中。将其放置在最方便操作的位置。作为背面清晰的视图,指示器将混合位于其后的背景视图。该背景的主要颜色帮助选择要使用的指示器样式。
对于一般用途,只需将活动指示器作为子视图添加到你要覆盖的窗口、视图、工具栏或导航栏。分配该指示器并使用一个框来初始化它,最好位于当前所使用的父视图中央。
通过将指示器的animating属性更新为YES来启动它。若要停止,将该属性设置为NO。Cocoa Touch会负责完成其余工作,在视图不使用时隐藏视图。
iPhone提供了几种不同样式的UIActivityIndicatorView类。UIActivityIndicator- ViewStyleWhite和UIActivityIndicatorViewStyleGray是最简洁的。黑色背景下最适合白色版本的外观,白色背景最适合灰色外观(如图4-7所示)。它非常瘦小,而且采用夏普风格。选择白色还是灰色时要格外注意。全白显示在白色背景下将不能显示任何内容。而UIActivityIndicatorViewStyleWhiteLarge只能用于深色背景。它提供最大、最清晰的指示器。秘诀4-6显示了创建这些简单的UIActivityIndicatorView实例的代码。
图4-7 UIActivityIndicatorView类提
供了一个简单的旋转轮,
这意味着将以相对较小的尺寸显示
向程序中添加UIActivityIndicatorView
用法一:只显示不停旋转的进度滚轮指示器。
//显示进度滚轮指示器
-(void)showWaiting {
progressInd=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:
UIActivityIndicatorViewStyleWhiteLarge];
progressInd.center=CGPointMake(self.view.center.x,240);
[self.navigationController.view addSubview:progressInd];
[progressInd startAnimating];
}
//消除滚动轮指示器
-(void)hideWaiting
{
[progressInd stopAnimating];
}
用法二:带有半透明背景的进度轮指示器。
//显示进度滚轮指示器
-(void)showWaiting:(UIView*)parent {
int width = 32, height = 32;
CGRect frame= CGRectMake(100,200, 110,70) ;//[parent frame]; //[[UIScreenmainScreen] applicationFrame];
int x = frame.size.width;
int y = frame.size.height;
frame = CGRectMake((x - width) / 2, (y - height) / 2, width, height);
UIActivityIndicatorView* progressInd =[[UIActivityIndicatorView alloc]initWithFrame:frame];
[progressIndstartAnimating];
progressInd.activityIndicatorViewStyle =UIActivityIndicatorViewStyleWhiteLarge;
frame = CGRectMake((x -70)/2, (y - height) / 2 + height, 80, 20);
UILabel *waitingLable =[[UILabel alloc] initWithFrame:frame];
waitingLable.text =@"Loading...";
waitingLable.textColor =[UIColor whiteColor];
waitingLable.font =[UIFont systemFontOfSize:15];
waitingLable.backgroundColor= [UIColor clearColor];
frame = CGRectMake(100, 200, 110, 70) ;//[parentframe];
UIView *theView = [[UIView alloc] initWithFrame:frame];
theView.backgroundColor =[UIColor blackColor];
theView.alpha = 0.7;
[theView addSubview:progressInd];
[theView addSubview:waitingLable];
[progressInd release];
[waitingLable release];
[theView setTag:9999];
[parent addSubview:theView];
[theView release];
}
//消除滚动轮指示器
-(void)hideWaiting
{
[[self.viewviewWithTag:9999]removeFromSuperview];
}
- 使用UIActivityIndicatorView
- 使用UIActivityIndicatorView
- 使用UIActivityIndicatorView
- 使用UIActivityIndicatorView
- UIActivityIndicatorView 使用
- 使用UIActivityIndicatorView
- 使用UIActivityIndicatorView
- 使用UIActivityIndicatorView
- 使用UIActivityIndicatorView
- 使用UIActivityIndicatorView
- 使用UIActivityIndicatorView
- UIActivityIndicatorView的详细使用
- UIActivityIndicatorView的详细使用
- UIActivityIndicatorView的使用方式
- UIActivityIndicatorView 的使用
- UIActivityIndicatorView的详细使用
- UIActivityIndicatorView的详细使用
- UIActivityIndicatorView的简单使用
- 管理数据库Database
- Java通过SSH2协议执行远程Shell脚本
- netlink测试程序的编写
- C++中return的含义
- suse9x64 下升级binutils版本 到2.20.51.0.2
- 使用UIActivityIndicatorView
- HDU 2544 奥运
- dotConnect for Oracle存储过程方法
- 使用WindowManager实现悬浮窗口
- Http协议详解
- 宁波工程学院 [1271] Nth Day is Which Day 输出第n天的日期 (要求算法很快速,解决超时)
- 修复:"故障模块名称: clr.dll"运行 Microsoft 的.NET Framework 4 基于应用程序时出现错误消息
- 太网帧类型
- 打开xshell等无法定位程序输入点*于动态链接库nssock2.dll上的问题解决方法