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

iOS UIActivityIndicatorView

时间:2015-07-04 10:58:47      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

#import "ViewController.h"

@interface ViewController ()

{

UIActivityIndicatorView *activity;

}

@end

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    UIButton *button1=[[UIButton alloc]initWithFrame:CGRectMake(50, 400, 100, 50)];

    [button1 setTitle:@"开始" forState:UIControlStateNormal];

    button1.backgroundColor=[UIColor orangeColor];

    [button1 addTarget:self action:@selector(aa:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:button1];

    UIButton *button2=[[UIButton alloc]initWithFrame:CGRectMake(180, 400, 100, 50)];

    [button2 setTitle:@"停止" forState:UIControlStateNormal];

    button2.backgroundColor=[UIColor purpleColor];

    [button2 addTarget:self action:@selector(bb:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:button2];

    activity=[[UIActivityIndicatorView  alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];

    //设置 风格;

    activity.activityIndicatorViewStyle=UIActivityIndicatorViewStyleWhiteLarge;

    //设置活动指示器的颜色

    activity.color=[UIColor redColor];

    //hidesWhenStopped默认为YES,会隐藏活动指示器。要改为NO

    /* activity.hidesWhenStopped=NO;

    //启动

    [activity startAnimating];

    //停止

    [activity stopAnimating];*/

    [self.view addSubview:activity];

    // Do any additional setup after loading the view, typically from a nib.

}

-(IBAction)aa:(id)sender

{

    [activity startAnimating];

}

-(IBAction)bb:(id)sender

{

    [activity stopAnimating];

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

@end

技术分享技术分享

创建

UIActivityIndicatorView* activityIndicatorView = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(100,100,100,100)];

属性设置风格:

1.activityIndicatorView.activityIndicatorViewStyle= UIActivityIndicatorViewStyleGray;

系统给你提供了3种风格:

1)UIActivityIndicatorViewStyleWhiteLarge 大型白色指示器

2)UIActivityIndicatorViewStyleWhite 标准尺寸白色指示器

3)UIActivityIndicatorViewStyleGray 灰色指示器,用于白色背景

启动和停止

1.[activityIndicatorView startAnimating ];//启动

2.[activityIndicatorView stopAnimating ];//停止

 

iOS UIActivityIndicatorView

标签:

原文地址:http://www.cnblogs.com/YuanYe1/p/4620236.html

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