Introduction to Swift Development: Activity indicator (Uiactivityindicatorview)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.