UIKit 框架之UIActivityIndicatorView

//

//  ViewController.m

//  UIActivityIndicatorView

//

//  Created by City--Online on 15/5/18.

//  Copyright (c) 2015年 XQB. All rights reserved.

//



#import "ViewController.h"



@interface ViewController ()

@property(nonatomic,strong) UIActivityIndicatorView *activityIndicatorView;

@end



@implementation ViewController



- (void)viewDidLoad {

    [super viewDidLoad];

    

    self.view.backgroundColor=[UIColor blackColor];

    

    UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];

    btn.frame=CGRectMake(100, 200, 50, 50);

    [btn setTitle:@"按钮" forState:UIControlStateNormal];

    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:btn];

//    typedef NS_ENUM(NSInteger, UIActivityIndicatorViewStyle) {

//        UIActivityIndicatorViewStyleWhiteLarge,   //大白 齿轮较大

//        UIActivityIndicatorViewStyleWhite,        //小白 齿轮较小

//        UIActivityIndicatorViewStyleGray,         //小灰

//    };



    _activityIndicatorView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

    _activityIndicatorView.frame=CGRectMake(100, 100, 50, 50);

    _activityIndicatorView.center=self.view.center;

    //YES 停止动画时隐藏 NO 停止时不再转

    _activityIndicatorView.hidesWhenStopped=NO;

    _activityIndicatorView.backgroundColor=[UIColor redColor];

    //齿轮颜色

    _activityIndicatorView.color=[UIColor blueColor];

    //开始动画

    [_activityIndicatorView startAnimating];

    [self.view addSubview:_activityIndicatorView];

}

-(void)btnClick:(id)sender

{

    //停止动画

    [_activityIndicatorView stopAnimating];

}



- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}



@end

 UIKit 框架之UIActivityIndicatorViewUIKit 框架之UIActivityIndicatorView

你可能感兴趣的:(Activity)