首页 > 其他 > 详细

UIActivityIndicatorView 的使用

时间:2015-01-04 17:02:52      阅读:222      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!