|  | 
| 7 | 7 | 
 | 
| 8 | 8 | import UIKit | 
| 9 | 9 | import SafariServices | 
| 10 |  | - | 
|  | 10 | +     | 
| 11 | 11 | extension String { | 
| 12 | 12 |     var withoutHtmlTags: String { | 
| 13 | 13 |     return self.replacingOccurrences(of: "<[^>]+>", with: "", options: | 
| @@ -68,30 +68,40 @@ class NewsTableViewController: UITableViewController { | 
| 68 | 68 | 
 | 
| 69 | 69 |     // Set the activity indicator into the main view | 
| 70 | 70 |     private func setLoadingScreen() { | 
| 71 |  | - | 
| 72 | 71 |         // Sets the view which contains the loading text and the spinner | 
| 73 | 72 |         let width: CGFloat = 120 | 
| 74 | 73 |         let height: CGFloat = 30 | 
| 75 |  | -        let x = (tableView.frame.width / 2) - (width / 2) | 
| 76 |  | -        let y = (tableView.frame.height / 2) - (height / 2) - (navigationController?.navigationBar.frame.height)! | 
| 77 |  | -        loadingView.frame = CGRect(x: x, y: y, width: width, height: height) | 
| 78 |  | - | 
| 79 |  | -        // Sets loading text | 
| 80 |  | -        loadingLabel.textColor = .gray | 
| 81 |  | -        loadingLabel.textAlignment = .center | 
| 82 |  | -        loadingLabel.text = "Loading..." | 
| 83 |  | -        loadingLabel.frame = CGRect(x: 0, y: 0, width: 140, height: 30) | 
| 84 |  | - | 
|  | 74 | +         | 
|  | 75 | +        loadingView.frame = CGRect(x: 0, y: 0, width: width, height: height) | 
|  | 76 | +        self.view.addSubview(loadingView) | 
|  | 77 | +         | 
| 85 | 78 |         // Sets spinner | 
| 86 | 79 |         spinner = UIActivityIndicatorView(style: .medium) | 
| 87 | 80 |         spinner.frame = CGRect(x: 0, y: 0, width: 30, height: 30) | 
| 88 | 81 |         spinner.startAnimating() | 
| 89 | 82 | 
 | 
|  | 83 | +        // Sets label | 
|  | 84 | +        loadingLabel.frame = CGRect(x: 30, y: 0, width: width, height: height) | 
|  | 85 | +        loadingLabel.textColor = .gray | 
|  | 86 | +        loadingLabel.text = Stefanfunctions().i18string(text: "strnewsloading") | 
|  | 87 | + | 
| 90 | 88 |         // Adds text and spinner to the view | 
| 91 | 89 |         loadingView.addSubview(spinner) | 
| 92 | 90 |         loadingView.addSubview(loadingLabel) | 
| 93 | 91 | 
 | 
| 94 |  | -        tableView.addSubview(loadingView) | 
|  | 92 | +        loadingView.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor).isActive = true | 
|  | 93 | +        loadingView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor).isActive = true | 
|  | 94 | + | 
|  | 95 | +        let totalView = UIView() | 
|  | 96 | +        totalView.translatesAutoresizingMaskIntoConstraints = false | 
|  | 97 | +        view.addSubview(totalView) | 
|  | 98 | +        totalView.addSubview(loadingView) | 
|  | 99 | +        NSLayoutConstraint.activate([ | 
|  | 100 | +            totalView.centerXAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerXAnchor), | 
|  | 101 | +            totalView.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor), | 
|  | 102 | +            totalView.heightAnchor.constraint(equalToConstant: height), | 
|  | 103 | +            totalView.widthAnchor.constraint(equalToConstant: width) | 
|  | 104 | +        ]) | 
| 95 | 105 |     } | 
| 96 | 106 | 
 | 
| 97 | 107 |     // Remove the activity indicator from the main view | 
|  | 
0 commit comments