UIActivityIndicatorView 等待指示器(转圈指示器)
#import "ViewController.h"@interface ViewController (){ //新建一个等待指示器(转圈指示器) UIActivityIndicatorView *myActivity; }@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; //新建一个等待指示器,设置样式(一共有三种,点进去就有) myActivity = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; //设置等待指示器的颜色 myActivity.backgroundColor = [UIColor redColor]; //设置等待指示器的位置(center-中心) myActivity.center = self.view.center; //给等待指示器设置倒圆角 myActivity.layer.cornerRadius = 5; myActivity.layer.masksToBounds = YES; //设置上面转着的圆圈的颜色 myActivity.color = [UIColor blueColor]; //将等待指示器添加到手机界面上 [self.view addSubview:myActivity]; //!!!很重要,让它可以显示并转动起来 [myActivity startAnimating]; //设置一个Button,点击后等待指示器会停止转动 UIButton *myButton = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 50, 50)]; myButton.backgroundColor = [UIColor purpleColor]; [myButton addTarget:self action:@selector(haha:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:myButton]; }//Button的方法-(void)haha:(id)a{ [myActivity stopAnimating];}