
------------------------------------------------------------------------------------------
//// VIEwController.swift// UIProgressVIEwSample//// Created by jinnchang on 15/4/2.// copyright (c) 2015年 Jinn Chang. All rights reserved.//import UIKitclass VIEwController: UIVIEwController { var button: UIbutton! var progressVIEw: UIProgressVIEw! var timer: NSTimer! var remainTime = 10 overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // Do any additional setup after loading the vIEw,typically from a nib. button = UIbutton.buttonWithType(.System) as UIbutton button.frame = CGRectMake(30,50,self.vIEw.frame.size.wIDth - 60,100) button.setTitle("开始计时",forState: .normal) button.addTarget(self,action: "buttonAction",forControlEvents: .touchUpInsIDe) progressVIEw = UIProgressVIEw(progressVIEwStyle: .bar) progressVIEw.frame = CGRectMake(30,200,100) progressVIEw.progress = 1.0 self.vIEw.addSubvIEw(button) self.vIEw.addSubvIEw(progressVIEw) } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. } /// 响应按钮点击事件 func buttonAction() { button.enabled = false timer = NSTimer.scheduledTimerWithTimeInterval(1,target: self,selector: "timerAction",userInfo: nil,repeats: true) timer.fire() } /// 响应定时器事件 func timerAction() { if(remainTime < 0) { timer.invalIDate() println("倒计时结束") } else { remainTime = remainTime - 1 let progressValue = float(remainTime)/10 progressVIEw.setProgress(progressValue,animated: true) } }} ------------------------------------------------------------------------------------------GitHub 上项目地址:UIProgressViewSample
控件更多相关属性及方法参考:UIProgressView Class Reference 文章最后更新时间:2015年4月3日11:39:23 总结
以上是内存溢出为你收集整理的Swift 简单控件示例:进度条(UIProgressView)全部内容,希望文章能够帮你解决Swift 简单控件示例:进度条(UIProgressView)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)