ActivityIndicator(菊花)的用法


1,在視圖文件中拖拽一個 Activity Indicator View並且聲明

#import <UIKit/UIKit.h>

@interface XViewController : UIViewController

@property (weak, nonatomic) IBOutlet UILabel *myLabel;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *myActivityIndicatorView;
@end

 

2,運用 startAnimating 和stopAnimating方法控制菊花是否轉動

//
//  XViewController.m
//  ssss
//
//

#import "XViewController.h"

@interface XViewController ()

@end

@implementation XViewController
@synthesize myLabel;
@synthesize myActivityIndicatorView;

-(void)myMethodName
{
    //加載此方法以后Label名為 welcome
    myLabel.text = @"welcome";
    //停止動畫
    [myActivityIndicatorView stopAnimating];
    //將菊花隱藏掉
    myActivityIndicatorView.hidden = YES;
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    [myActivityIndicatorView startAnimating];//加載的時候動畫開始運行
    //2秒后運行名為myMethodName的方法
    [self performSelector:@selector(myMethodName) withObject:nil afterDelay:2.0f];
  //selector(方法名)

} - (void)viewDidUnload { [self setMyLabel:nil]; [self setMyActivityIndicatorView:nil]; [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } @end


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM