I have a picture in the center of my cell, I added a leading and a trailing to center this, it works in a lot of devices but when I try to display this on the iPhone 4 the screen is too small so the length of the leading and trailing are too longs so the picture is compressed and we could not see the image.
So I want to do calculations like leading = screen_width/3 and trailing = screen_width/3 in SWIFT.
It is possible and it is a good solution ? How to do this or here is an better way ?
When there is such requirement that you want to show View A in centre of View B, I recommend the following constraints:
- View A : Equal Width to superview (i.e. View B), with multiplier. (In your case 1/3 = 0.33).
- View B : Equal Height to superview (i.e. View A), with multiplier. (In your case 1/3 = 0.33).
- View A Center Vertically to superview (i.e. View B).
- View A Center Horizontally to superview (i.e. View B).