iOS 기본 제어 -- - UIACtivityIndicatorView

1858 단어 iOS컨트롤
//
//  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

좋은 웹페이지 즐겨찾기