IOS学习笔记(八)之UIActivityIndicatorView(活动指示器视图)的基本概念和使用方法

  IOS学习笔记(八)之UIActivityIndicatorView(活动指示器视图)(博客地址:http://blog.csdn.net/developer_jiangqq)

      Author:hmjiangqq

      Email:jiangqqlmj@163.com

UIActivityIndicatorView:

作用:进行提示用户当前正在加载进度,该控件可以消除用户等待的心理事件,增加用户体验。

首先来看下官方解说:


Use an activity indicator to show that a task is in progress. An activity indicator appears as a “gear” that is either spinning or stopped.

You control when an activity indicator animates by calling the startAnimating and stopAnimating methods. To automatically hide the activity indicator when animation stops, set the hidesWhenStopped property to YES.

常用的属性和方法:


- (void)startAnimating; //开始进度动画

- (void)stopAnimating; //停止进度动画

- (BOOL)isAnimating;  //检测是否动画在执行

实例代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor redColor];
    
    UIActivityIndicatorView *activityView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    activityView.center=CGPointMake(160, 155);
    [activityView startAnimating];
    [self.window addSubview:activityView];
    [activityView release];
    
    //定时3s之后,自动停止运行
    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(test:) userInfo:activityView repeats:NO];
    
    [self.window makeKeyAndVisible];
    return YES;
}

-(void)test:(NSTimer *)timer{
    UIActivityIndicatorView *view=timer.userInfo;
    [view stopAnimating];
    NSLog(@"进度结束...");
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值