//创建活动指示控件及大小
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];
}