Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ProgressDialogView: UIView {
  4.  
  5. let activityIndictor: UIActivityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: UIActivityIndicatorViewStyle.white)
  6.  
  7. init() {
  8. super.init(frame: CGRect(x: 0,
  9. y: 0,
  10. width: 0,
  11. height: 0))
  12. self.setup()
  13. }
  14.  
  15. required init?(coder aDecoder: NSCoder) {
  16. super.init(coder: aDecoder)
  17. self.setup()
  18. }
  19.  
  20. func setup() {
  21. self.addSubview(activityIndictor)
  22. activityIndictor.startAnimating()
  23. }
  24.  
  25. override func didMoveToSuperview() {
  26. super.didMoveToSuperview()
  27.  
  28. if let superview = self.superview {
  29.  
  30. let width = superview.frame.size.width
  31. let height = superview.frame.size.height
  32. self.frame = CGRect(x: 0,
  33. y: 0,
  34. width: width,
  35. height: height)
  36. self.backgroundColor = UIColor.init(white: 0.0, alpha: 0.5)
  37.  
  38. let activityIndicatorSize: CGFloat = 40
  39. activityIndictor.frame = CGRect(x: width / 2 - activityIndicatorSize / 2,
  40. y: height / 2 - activityIndicatorSize / 2,
  41. width: activityIndicatorSize,
  42. height: activityIndicatorSize)
  43. layer.masksToBounds = true
  44. }
  45. }
  46.  
  47. func show() {
  48. self.isHidden = false
  49. }
  50.  
  51. func hide() {
  52. self.isHidden = true
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement