We are placing a temporary label over our UITableViewController view
when we need to show a status message. The view goes directly beneath the UINavigationBar. This works well but the statusView
scrolls with the table and will disappear as the table scrolls up. How can you fix the statusView position even as the table scrolls?
Update:
What almost works as inspired by another question is to use the TableViewDelegate method to fix the statusView position:
override func scrollViewDidScroll(_ scrollView: UIScrollView) {
var newFrame = statusView.frame
newFrame.origin.x = 0
newFrame.origin.y = self.tableView.contentOffset.y + self.navigationController!.navigationBar.bounds.height
statusView.frame = newFrame
}
It places our statusView
bar in a fixed position but it's partially underneath the navigation bar. Seems like we just need to tweak the newFrame.origin.y
logic....
Update 2:
Per https://stackoverflow.com/a/40202931/47281 just needed to include the status bar:
newFrame.origin.y = self.tableView.contentOffset.y + self.navigationController!.navigationBar.frame.size.height + UIApplication.shared.statusBarFrame.height