ios - Swift: Best way to add one single image to all cells in a UITableView -


i have large image background of table cells (to support devices , orientations). since want save memory thought idea make uiimage correct dimensions in viewdidload:

let bgimage = uiimage(named: "cellbg_001.png") var bgview = uiimageview() bgview = uiimageview(image: bgimage!) bgview.frame = cgrect(x: 0, y: 0, width: cellwidth, height: cellheight) 

and re-use every cell. learned view can have 1 parent view , ended same code, in cellforrowatindexpath-method. feel bad ; ) there better way this?

you should create 1 uiimage object , assign uiimageviews in cells. since uitableview reusing cells shouldn't have problems performance if dequeueing cells.