i have UITableViewController, and I'm trying to set a image background. the issue is the background image does not fit the whole screen, in other words, the image background does not stretch with the table cells. this my code
let imgView = UIImageView(frame: self.tableView.frame)
let img = UIImage(named: "b2")
imgView.image = img
imgView.frame = CGRectMake(0, 0, self.tableView.frame.width, self.tableView.frame.height)
imgView.contentMode = UIViewContentMode.ScaleAspectFill
self.tableView.addSubview(imgView)
self.tableView.sendSubviewToBack(imgView)
backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TableViewBackground. png"]]; Thank you in advance!
Try with this code:
tableView.backgroundView = UIImageView(image: UIImage(named: "640x1136.png"))
Add this code in ViewDidLoad
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With