S.Verma S.Verma - 1 year ago 65
iOS Question

How do I put an UIImageView in the center of a tableView

I want my image to be in the center in the x axis, I'm writing this code :

let emptyImage=UIImageView(frame: CGRect(x: (UIScreen.main.bounds.width)/2 ,y: 200 , width: 50, height: 50))

but it doesn't work.

Answer Source

try this

let emptyImage = UIImageView(frame: CGRect(x: UIScreen.main.bounds.width/2 - 50/2, y: 200, width: 50, height : 50)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download