Guest User

Untitled

a guest
Mar 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. // /////////////////// //
  2. // MARK: LOADING SPINNER //
  3. // ////////////////// //
  4.  
  5. /**
  6. Show loading text
  7. */
  8. private func showLoading(){
  9. // Instantiate the label
  10. loading = UILabel(frame: CGRect(x: 0, y: view.frame.height / 3 , width: view.frame.width, height: 40))
  11. // set the text
  12. loading.text = "Searching "
  13. // set the alignment
  14. loading.textAlignment = .center
  15. //set the font
  16. loading.font = UIFont(name: "Delm-medium", size: 40)
  17. //set text color
  18. loading.textColor = UIColor.white
  19.  
  20. view.addSubview(loading)
  21. }
  22. /**
  23. Remove Loading Text
  24. */
  25. private func hideLoading(){
  26. loading.removeFromSuperview()
  27. }
  28.  
  29. /**
  30. Instantiate, configure and show UIActivityIndicator
  31. */
  32. private func showSpinner(){
  33.  
  34. // Position Activity Indicator in the center of the main view
  35. myActivityIndicator.center = view.center
  36.  
  37. // If needed, you can prevent Acivity Indicator from hiding when stopAnimating() is called
  38. myActivityIndicator.hidesWhenStopped = false
  39.  
  40. // Start Activity Indicator
  41. myActivityIndicator.startAnimating()
  42.  
  43. //Show spinner
  44. view.addSubview(myActivityIndicator)
  45. }
  46. /**
  47. Kill UIActivityIndicator
  48. */
  49. private func hideSpinner(){
  50. myActivityIndicator.removeFromSuperview()
  51. }
  52. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
  53. self.view.endEditing(true)
  54. }
  55. func textFieldShouldReturn(_ textField: UITextField) -> Bool {
  56. textField.resignFirstResponder()
  57. searchImage()
  58. return(true)
  59. }
Add Comment
Please, Sign In to add comment