Guest User

Untitled

a guest
Jan 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. import UIKit
  2.  
  3. class LoadingScreen: UIViewController {
  4.  
  5.  
  6. var time : Float = 0.0
  7. var timer: NSTimer?
  8.  
  9. @IBOutlet weak var progressView: UIProgressView!
  10.  
  11.  
  12. override func viewDidLoad() {
  13. super.viewDidLoad()
  14.  
  15. // Do stuff
  16.  
  17. timer = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector:Selector("setProgress"), userInfo: nil, repeats: true)
  18.  
  19. }//close viewDidLoad
  20.  
  21. func setProgress() {
  22. time += 0.1
  23. progressView.progress = time / 3
  24. if time >= 3 {
  25. timer!.invalidate()
  26. }
  27. }
  28.  
  29. }
  30.  
  31. override func viewDidAppear(animated: Bool)
  32. {
  33. super.viewDidAppear(animated)
  34.  
  35. UIView.animateWithDuration(3, animations: { () -> Void in
  36. self.progressView.setProgress(1.0, animated: true)
  37. })
  38. }
  39.  
  40. func setProgress() {
  41. time += 0.1
  42. progressView.setProgress(time / 3, animated: true)
  43. if time >= 3 {
  44. timer!.invalidate()
  45. }
  46. }
  47.  
  48. timer = NSTimer.scheduledTimerWithTimeInterval(0.001, target: self, selector:Selector("setProgress"), userInfo: nil, repeats: true)
  49.  
  50. func setProgress() {
  51. time += 0.001
  52. progressView.setProgress(time / 3, animated: true)
  53. if time >= 3 {
  54. timer!.invalidate()
  55. }
  56. }
  57.  
  58. timer = Timer.scheduledTimer(timeInterval: 0.001, target: self, selector: #selector(setProgress), userInfo: nil, repeats: true)
  59.  
  60. func setProgress() {
  61. time += 0.001
  62. downloadProgressBar.setProgress(time / 3, animated: true)
  63. if time >= 3 {
  64. self.time = 0.001
  65. downloadProgressBar.progress = 0
  66. let color = self.downloadProgressBar.progressTintColor
  67. self.downloadProgressBar.progressTintColor = self.downloadProgressBar.trackTintColor
  68. self.downloadProgressBar.trackTintColor = color
  69. }
Add Comment
Please, Sign In to add comment