Search code examples
swiftbackground-imagefullscreen

Swift: Make the background image of UITableViewController embedded in Navigation Controller fill the entire screen


I managed to create translucent and rounded UITableViewCells in a UITableViewController that is embedded inside a Navigation Controller with this line of code in viewDidLoad():

    tableView.backgroundView = UIImageView(image: UIImage(named: "nightTokyo"))

Background image does not fill entire phone screen

But I want the background image to fill the entire phone screen. I changed the code (and only this line of code) to:

    navigationController?.view = UIImageView(image: UIImage(named: "nightTokyo"))

Now the background image fills up the entire phone screen, but my table and even the iPhone's time and battery indicator icons are missing.

Background image fills the entire phone screen but everything else is missing

What I want is for the background image to fill the entire screen, but the tableView, its cells, the iPhone time, battery level icon, etc. to remain displayed.


Solution

  • navigationController?.setNavigationBarHidden(true, animated: true)