UIActivityIndicatorView活动指示条

来源:互联网 发布:java解析excel文件 编辑:程序博客网 时间:2024/05/20 18:40
活动指示条中 :

开始  startAnimating

停止  stopAnimating

aiv.hidesWhenStopped=NO;   停止时仍然可见

aiv.activityIndicatorViewStyle=UIActivityIndicatorViewStyleGray;     活动指示类型中,有灰色,白色,大白色,其中大白色和其他不同以外,不知道和直接.color=[uicolor ..]有什么不同



    self.window = [[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]];

    self.window.backgroundColor=[UIColorwhiteColor];

    aiv = [[UIActivityIndicatorViewalloc]initWithFrame:CGRectMake(50,50, 50,50)];

    aiv.hidesWhenStopped=NO;

//颜色和其他的不一样

    aiv.color = [UIColor grayColor];

    UIButton * bu1 = [[UIButtonalloc]initWithFrame:CGRectMake(50,120, 80,50)];

    bu1.backgroundColor=[UIColorblackColor];

    [bu1 setTitle:@"走一个"forState:UIControlStateNormal];

    

    UIButton * bu2 = [[UIButtonalloc]initWithFrame:CGRectMake(50,200, 80,50)];

    bu2.backgroundColor=[UIColorblackColor];

    [bu2 setTitle:@"停一停"forState:UIControlStateNormal];


    //[aiv startAnimating];

   // aiv.activityIndicatorViewStyle=UIActivityIndicatorViewStyleGray;

    aiv.backgroundColor=[UIColorwhiteColor];

    [bu1 addTarget:selfaction:@selector(act1:)forControlEvents:UIControlEventTouchUpInside];

    [bu2 addTarget:selfaction:@selector(act2:)forControlEvents:UIControlEventTouchUpInside];

    [self.windowaddSubview:bu1];

     [self.windowaddSubview:bu2];

    [self.windowaddSubview:aiv];

    [self.windowmakeKeyAndVisible];

    returnYES;

}


-(void)act1:(UIButton * )sender

{

    [aivstartAnimating];

}


-(void)act2:(UIButton * )sender

{

    [aivstopAnimating];

}




0 0