iOS基础控件---UIActivityIndicatorView

//
//  ViewController.h
//  UIActivityIndicatorView
//
//  Created by pengjiaxin on 2017/10/16.
//  Copyright © 2017年 pengjiaxin. All rights reserved.
//

#import 

@interface ViewController : UIViewController
{
    
    //等待提示对象
    //当下载,或加载较大的文件时,可以显示此控件,处于等待状态
    UIActivityIndicatorView *_activityIndicator;
}


@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;


@end
//
//  ViewController.m
//
//
//  Created by pengjiaxin on 2017/10/16.
//  Copyright © 2017年 pengjiaxin. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@end

@implementation ViewController
//同步---

@synthesize activityIndicator = _activityIndicator;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100, 100 + 100, 100, 40);
    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    [button setTitle:@"等待对话框" forState:UIControlStateNormal];
    
    
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    
}

-(void)buttonAction:(UIButton *)button{
    
    //宽高不可变更
    _activityIndicator = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(150, 200, 80, 80)];
    //小白,小灰,大白
    _activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
    [self.view addSubview:_activityIndicator];
    
    //启动动画并显示
    [_activityIndicator startAnimating];
    //结束动画并隐藏
    //        [_activityIndicator stopAnimating];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end


你可能感兴趣的:(iOS,控件)