Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // /////////////////// //
- // MARK: LOADING SPINNER //
- // ////////////////// //
- /**
- Show loading text
- */
- private func showLoading(){
- // Instantiate the label
- loading = UILabel(frame: CGRect(x: 0, y: view.frame.height / 3 , width: view.frame.width, height: 40))
- // set the text
- loading.text = "Searching "
- // set the alignment
- loading.textAlignment = .center
- //set the font
- loading.font = UIFont(name: "Delm-medium", size: 40)
- //set text color
- loading.textColor = UIColor.white
- view.addSubview(loading)
- }
- /**
- Remove Loading Text
- */
- private func hideLoading(){
- loading.removeFromSuperview()
- }
- /**
- Instantiate, configure and show UIActivityIndicator
- */
- private func showSpinner(){
- // Position Activity Indicator in the center of the main view
- myActivityIndicator.center = view.center
- // If needed, you can prevent Acivity Indicator from hiding when stopAnimating() is called
- myActivityIndicator.hidesWhenStopped = false
- // Start Activity Indicator
- myActivityIndicator.startAnimating()
- //Show spinner
- view.addSubview(myActivityIndicator)
- }
- /**
- Kill UIActivityIndicator
- */
- private func hideSpinner(){
- myActivityIndicator.removeFromSuperview()
- }
- override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
- self.view.endEditing(true)
- }
- func textFieldShouldReturn(_ textField: UITextField) -> Bool {
- textField.resignFirstResponder()
- searchImage()
- return(true)
- }
Add Comment
Please, Sign In to add comment