码迷,mamicode.com
首页 > 移动开发 > 详细

iOS:等待控件

时间:2014-10-09 01:23:07      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   os   ar   sp   div   

定义:

@interface ViewController ()
{
    UIActivityIndicatorView *testActivityIndicator;
}

实例化,开始旋转:

-(void) showWaitStatus
{
    NSLog(@"wait...");
    testActivityIndicator =
            [[UIActivityIndicatorView alloc]
            initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    
    CGRect rect = self.view.frame;
    testActivityIndicator.center = CGPointMake(rect.size.width / 2, rect.size.height / 2);
    [self.view addSubview:testActivityIndicator];
    testActivityIndicator.color = [UIColor redColor]; // iOS5 引入指定颜色
    [testActivityIndicator startAnimating];           // 开始旋转
    [testActivityIndicator setHidesWhenStopped:YES];  // 当旋转结束时隐藏
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [self showWaitStatus];
}

停止旋转:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [testActivityIndicator stopAnimating];
}

 

iOS:等待控件

标签:des   style   blog   color   io   os   ar   sp   div   

原文地址:http://www.cnblogs.com/code-style/p/4011978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!