Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class LoadingScreen: UIViewController {
- var time : Float = 0.0
- var timer: NSTimer?
- @IBOutlet weak var progressView: UIProgressView!
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do stuff
- timer = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector:Selector("setProgress"), userInfo: nil, repeats: true)
- }//close viewDidLoad
- func setProgress() {
- time += 0.1
- progressView.progress = time / 3
- if time >= 3 {
- timer!.invalidate()
- }
- }
- }
- override func viewDidAppear(animated: Bool)
- {
- super.viewDidAppear(animated)
- UIView.animateWithDuration(3, animations: { () -> Void in
- self.progressView.setProgress(1.0, animated: true)
- })
- }
- func setProgress() {
- time += 0.1
- progressView.setProgress(time / 3, animated: true)
- if time >= 3 {
- timer!.invalidate()
- }
- }
- timer = NSTimer.scheduledTimerWithTimeInterval(0.001, target: self, selector:Selector("setProgress"), userInfo: nil, repeats: true)
- func setProgress() {
- time += 0.001
- progressView.setProgress(time / 3, animated: true)
- if time >= 3 {
- timer!.invalidate()
- }
- }
- timer = Timer.scheduledTimer(timeInterval: 0.001, target: self, selector: #selector(setProgress), userInfo: nil, repeats: true)
- func setProgress() {
- time += 0.001
- downloadProgressBar.setProgress(time / 3, animated: true)
- if time >= 3 {
- self.time = 0.001
- downloadProgressBar.progress = 0
- let color = self.downloadProgressBar.progressTintColor
- self.downloadProgressBar.progressTintColor = self.downloadProgressBar.trackTintColor
- self.downloadProgressBar.trackTintColor = color
- }
Add Comment
Please, Sign In to add comment