标签:ios swift 活动指示器 uiactivityindicatorv
转载请声明出处:http://blog.csdn.net/jinnchang/article/details/44828021// // ViewController.swift // UIActivityIndicatorViewSample // // Created by jinnchang on 15/4/1. // Copyright (c) 2015年 Jinn Chang. All rights reserved. // import UIKit class ViewController: UIViewController { var button1: UIButton! var button2: UIButton! var activityIndicatorView: UIActivityIndicatorView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. // 定义一个显示 activityIndicatorView 的按钮 button1 = UIButton.buttonWithType(UIButtonType.System) as UIButton button1.frame = CGRectMake(self.view.frame.width/2 - 200, 50, 400, 50) button1.setTitle("显示", forState: UIControlState.Normal) button1.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside) button1.tag = 1 // 定义一个隐藏 activityIndicatorView 的按钮 button2 = UIButton.buttonWithType(UIButtonType.System) as UIButton button2.frame = CGRectMake(self.view.frame.width/2 - 200, 150, 400, 50) button2.setTitle("隐藏", forState: UIControlState.Normal) button2.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside) button2.tag = 2 // 定义一个 activityIndicatorView activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.White) activityIndicatorView.frame = CGRectMake(self.view.frame.size.width/2 - 50, 250, 100, 100) activityIndicatorView.hidesWhenStopped = true activityIndicatorView.color = UIColor.blackColor() self.view.addSubview(button1) self.view.addSubview(button2) self.view.addSubview(activityIndicatorView) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } /// 按钮响应事件 func buttonAction(sender: UIButton) { let num = sender.tag switch num { case 1: activityIndicatorView.startAnimating() case 2: activityIndicatorView.stopAnimating() default: break } } }------------------------------------------------------------------------------------------
文章最后更新时间:2015年4月2日09:41:40。更多资料参考:
UIActivityIndicatorView
Class Reference
UIKit
User Interface Catalog: Activity Indicators
论 Swift 开发入门:活动指示器(UIActivityIndicatorView)
标签:ios swift 活动指示器 uiactivityindicatorv
原文地址:http://blog.csdn.net/jinnchang/article/details/44828021