【UIActivityIndicator活动指示器控件】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/winer888/article/details/48501531

//创建活动指示控件及大小

    act=[[UIActivityIndicatorViewalloc]initWithFrame:CGRectMake(40,40, 40, 40)];

    //默认是停止时不显示(yes)

    act.hidesWhenStopped=NO;

    //设定他的样式

    act.activityIndicatorViewStyle=UIActivityIndicatorViewStyleGray;

    //控件的背景颜色

    //act.backgroundColor=[UIColor greenColor];

    //环状的颜色

    act.color=[UIColorblackColor];

    

    //创建两按钮 

    UIButton *b1=[[UIButtonalloc]initWithFrame:CGRectMake(85,130, 80,60)];

    UIButton *b2=[[UIButtonalloc]initWithFrame:CGRectMake(170,130, 80,60)];

    b1.backgroundColor=[UIColorgreenColor];

    b2.backgroundColor=[UIColorgreenColor];

    [b1 setTitle:@"启动"forState:UIControlStateNormal];

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

    //添加控制动作

    [b1 addTarget:selfaction:@selector(startTap)forControlEvents:UIControlEventTouchUpInside];

    [b2 addTarget:selfaction:@selector(stopTap)forControlEvents:UIControlEventTouchUpInside];

    

    //添加到窗口上

    [self.windowaddSubview:b1];

    [self.windowaddSubview:b2];

    [self.windowaddSubview:act];

    return YES;

}

-(void)startTap

{

    //控件启动

    [actstartAnimating];

}

-(void)stopTap

{

    //控件停止

    [actstopAnimating];

}

猜你喜欢

转载自blog.csdn.net/winer888/article/details/48501531