Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 9e16c28

Browse files
committed
Fixed center loading text
1 parent 9b1315c commit 9e16c28

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

Shared (App)/en.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@
5252
"strdesdeveloper" = "Find, and Report Issues!";
5353
"strsocial" = "SOCIAL COMMUNITY";
5454
"strdessocial" = "Follow and interact with other members!";
55+
"strnewsloading" = "Loading…";

Shared (App)/nl.lproj/Localizable.strings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@
5252
"strdesdeveloper" = "Zoek en meld problemen!";
5353
"strsocial" = "SOCIALE GEMEENSCHAP";
5454
"strdessocial" = "Volg en communiceer met andere leden!";
55+
"strnewsloading" = "Laden…";

iOS (App)/NewsTableViewController.swift

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import UIKit
99
import SafariServices
10-
10+
1111
extension String {
1212
var withoutHtmlTags: String {
1313
return self.replacingOccurrences(of: "<[^>]+>", with: "", options:
@@ -68,30 +68,40 @@ class NewsTableViewController: UITableViewController {
6868

6969
// Set the activity indicator into the main view
7070
private func setLoadingScreen() {
71-
7271
// Sets the view which contains the loading text and the spinner
7372
let width: CGFloat = 120
7473
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+
8578
// Sets spinner
8679
spinner = UIActivityIndicatorView(style: .medium)
8780
spinner.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
8881
spinner.startAnimating()
8982

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+
9088
// Adds text and spinner to the view
9189
loadingView.addSubview(spinner)
9290
loadingView.addSubview(loadingLabel)
9391

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+
])
95105
}
96106

97107
// Remove the activity indicator from the main view

0 commit comments

Comments
 (0)