I want to set a background image in a UITableView when the list is empty. I installed it using the following code. It is clearly visible on the iPhone 5. But showing some space in the iPhone 6 devices.
Please, help. Im a beginner for iOS development.
@IBOutlet var tableView: UITableView!
let bgView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: tableView.frame.size.height))
let ivImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: tableView.frame.size.height))
ivImageView.image = image
ivImageView.tintColor = UIColor.green
ivImageView.contentMode = UIViewContentMode.scaleAspectFit
ivImageView.alpha = 0.05
bgView.addSubview(ivImageView)
tableView.backgroundView = bgView
tableView.backgroundView?.layoutIfNeeded()
tableView.backgroundView?.layoutSubviews()

user7587085
source
share