码迷,mamicode.com
首页 > 其他好文 > 详细

UIActivityIndicatorView 的使用

时间:2015-01-04 17:03:29      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:

//
//  UIActivityIndicator.m
//  ToolBar
//
//  Created by lanouhn on 15/1/3.
//  Copyright (c) 2015 niutiantian. All rights reserved.
//

#import "UIActivityIndicator.h"

@interface UIActivityIndicator ()
{
    UIActivityIndicatorView *activityView;
}
@end

@implementation UIActivityIndicator

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    UIActivityIndicatorView: 风火轮视图,作用是提醒用户正在加载数据
    
        //风火轮的样式
//    UIActivityIndicatorViewStyleWhiteLarge大型白色指示器
//    UIActivityIndicatorViewStyleWhite标准尺寸白色只指示器
//    UIActivityIndicatorViewStyleGray灰色指示器,用于白色背景

    activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    activityView.frame = CGRectMake(0, 0, 40, 40);
    activityView.center = self.view.center;
        //设置颜色
    activityView.color = [UIColor redColor];
    
        //指示器停止后自动隐藏
    activityView.hidesWhenStopped = YES;
    
    [self.view addSubview:activityView];
    [activityView release];
    
    UIButton *starButton = [UIButton buttonWithType:UIButtonTypeSystem];
    starButton.frame = CGRectMake(100, 100, 40, 40);
    [starButton setTitle:@"开始" forState:UIControlStateNormal];
    
    [starButton addTarget:self action:@selector(starAnimation) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.view addSubview:starButton];
    
    UIButton *stopButton = [UIButton buttonWithType:UIButtonTypeSystem];     stopButton.frame = CGRectMake(100, 160, 40, 40);     [stopButton setTitle:@"停止" forState:UIControlStateNormal];     [stopButton addTarget:self action:@selector(stopAnimation) forControlEvents:UIControlEventTouchUpInside];     [self.view addSubview:stopButton];      } - (void)starAnimation {     [activityView startAnimating];//开启动画 } - (void)stopAnimation {     [activityView stopAnimating];//关闭动画 } @end

 

UIActivityIndicatorView 的使用

标签:

原文地址:http://www.cnblogs.com/tian-sun/p/4201373.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!