reprint Please declare source: http://blog.csdn.net/jinnchang/article/details/44828021
------------------------------------------------------------------------------------------
code Example
viewcontroller.swift//uiactivityindicatorviewsample////Created by Jinnchang on 15/4/1.//Copyright (c) 2015 Ji NN Chang. All rights Reserved.//import Uikitclass Viewcontroller:uiviewcontroller {var button1:uibutton! var button2:uibutton! var activityindicatorview:uiactivityindicatorview! Override Func Viewdidload () {super.viewdidload ()//Do any additional setup after loading the view, typical Ly from a nib. Define a button that displays Activityindicatorview button1 = Uibutton.buttonwithtype (Uibuttontype.system) as UIButton Butto N1.frame = CGRectMake (SELF.VIEW.FRAME.WIDTH/2-$, +, +) Button1.settitle ("Show", FORSTATE:UICONTROLSTATE.N Ormal) Button1.addtarget (Self, Action: "Buttonaction:", forControlEvents:UIControlEvents.TouchUpInside) but Ton1.tag = 1//define a button that hides activityindicatorview button2 = Uibutton.buttonwithtype (uibuttontype.syst EM) as UIButton button2.frame =CGRectMake (SELF.VIEW.FRAME.WIDTH/2) button2.settitle ("hidden", ForState:UIControlState.Normal) Button2.addtarget (Self, Action: "Buttonaction:", forControlEvents:UIControlEvents.TouchUpInside) Button2.tag = 2//define a Activityindicatorview Activityindicatorview = Uiactivityindicatorview (activityindicatorst Yle:UIActivityIndicatorViewStyle.White) Activityindicatorview.frame = CGRectMake (SELF.VIEW.FRAME.SIZE.WIDTH/2-50 , activityindicatorview.hideswhenstopped = True Activityindicatorview.color = Uicolor.blackco Lor () Self.view.addSubview (button1) Self.view.addSubview (button2) Self.view.addSubview (activi Tyindicatorview)} override func didreceivememorywarning () {super.didreceivememorywarning ()//Dispos E of any resources the can be recreated. }///button response event func buttonaction (Sender:uibutton) {Let num = Sender.tag SWITCH num {case 1:activityindicatorview.startanimating () case 2:ACTIVITYINDICATORVIEW.S Topanimating () Default:break}}}
------------------------------------------------------------------------------------------
results show
------------------------------------------------------------------------------------------
ConclusionProject on GitHub address: uiactivityindicatorviewsample
Article last updated: April 2, 2015 09:41:40. For more information, refer to:
Uiactivityindicatorview Class Reference
UIKit User Interface catalog:activity indicators
Introduction to Swift Development: Activity indicator (Uiactivityindicatorview)