UIActivityIndicatorView 的使用

//
//  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

时间: 2024-10-07 00:45:17

UIActivityIndicatorView 的使用的相关文章

[Swift] UKIit学习之活动指示器UIActivityIndicatorView

UIActivityIndicatorView UIActivityIndicatorView(活动指示器)控件,也就是环形进度条,也就是Loading效果. UIActivityIndicatorView的创建: (1) 在Stroyboard中使用Ctrl+Drag拖拽法创建 (2) 代码创建: let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle:             UIActivityIndic

ios 系统自带的菊花(UIActivityIndicatorView)指示器

// //  RootViewController.m //  UIActivityIndicatorViewDemo // //  Created by Dubai on 15/4/28. //  Copyright (c) 2015年 Dubai. All rights reserved. // #import "RootViewController.h" @interface RootViewController () @property (strong, nonatomic)

UIActivityIndicatorView

UIActivityIndicatorView 1. activityIndicatorViewStyle 设置指示器的样式 UIActivityIndicatorViewStyleWhiteLarge UIActivityIndicatorViewStyleWhite  (默认样式) UIActivityIndicatorViewStyleGray    2.hidesWhenStopped 当停止动画的时候,是否隐藏.默认为YES. 3. 实例化指示器对象,根据样式设置尺寸,不需要手动设置.

UIActivityIndicatorView、UIProgressView 活动与进度指示器-iOS开发

活动指示器(UIActivityIndicatorView)可以告知用户有一个操作正在进行中.进度指示器(UIProgressView )也具有同样功能,而且还可以告知用户离操作结束还多远. 这两个指示器都是派生自UIView,所以他们是视图,也可以附着在视图上. 一.UIActivityIndicatorView 活动指示器 1.创建 UIActivityIndicatorView* activityIndicatorView = [ [ UIActivityIndicatorView  al

UIActivityIndicatorView的使用方法(旋转动画)

- (void)viewDidLoad { [super viewDidLoad]; //创建UIActivityIndicatorView并设置样式:WhiteLarge为37 * 37,Gray和White为20 * 20 _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; //设置对象的位置,大小

Loading效果 UIActivityIndicatorView

//初始化: UIActivityIndicatorView* indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; //设置显示样式,见UIActivityIndicatorViewStyle的定义 indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; //设置显示位置 [i

iOS开发——UI篇Swift篇&UIActivityIndicatorView

UIActivityIndicatorView 1 override func viewDidLoad() { 2 super.viewDidLoad() 3 4 titleLabel.text = titleString 5 6 // Do any additional setup after loading the view. 7 8 //创建活动指示器 9 var activityView:UIActivityIndicatorView = UIActivityIndicatorView(

UIActivityIndicatorView活动指示器

活动指示器(UIActivityIndicatorView)可以告知用户有一个操作正在进行中.派生自UIView,所以他是视图,也可以附着在视图上. 一.创建 UIActivityIndicatorView* activityIndicatorView = [ [ UIActivityIndicatorView alloc ]initWithFrame:CGRectMake(250.0,20.0,30.0,30.0)]; 二. 属性设置风格: activityIndicatorView.acti

UI第十一节——UIActivityIndicatorView

- (void)viewDidLoad {    [super viewDidLoad];        // 创建一个UIActivityIndicatorView,大小是固定的    UIActivityIndicatorView *aiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];        // 设置中心点    a

UI中一些不常用的控件UIActivityIndicatorView、UIProgressView、UISegmentedControl、UIStepper、UISwitch、UITextView、UIAlertController

1 //UIActivityIndicatorView //小菊花,加载 2 3 #import "ActivityIndicatorVC.h" 4 5 @interface ActivityIndicatorVC (){ 6 UIActivityIndicatorView *_activity ; 7 } 8 9 @end 10 11 @implementation ActivityIndicatorVC 12 13 -(void)viewDidLoad{ 14 [super vie