Search code examples
uiviewsizemeasurement

Positioning image on a custom view, clarification needed


I have a view sized 320 x 376

On top of this view, i'd like to place a UIImageView leaving 4 (not sure what is the unit of measurements here) points to each size. This (i hope) will create a frame around the image.

So, from the stand point of the view,

  • Starting x,y coordinates will be 4 x 4.
  • Calculating the width of the top view, i 320 - 4 - 4 = 312
  • Calculating the height of the top view, i 376 - 4 - 4 = 368

When said measurements are in place, however i get

enter image description here

enter image description here

Why am i not seeing a 4 points buffer towards the bottom?


Solution

  • Tested with your params, it's ok for me :

    enter image description here

    The only reason that I found to explain why this happens is because the view that is behind the 2 others (border view + image view) is shorter than 376, so it hides the bottom of your views :

    (here, it's the green one)

    OK
    enter image description here

    Too short
    enter image description here