ios - UIImageView won't retain a square shape. -


i'm not sure problem is, mean working fine 1 day, , woke , broken. here's i'm dealing with.

i have view height: 80, width: 80 , image height: 76, width: 76 image child-view view 80x80. centering image 2px border around view, give image "border" feel. (yes, know can in code editing image layer).

anyway, in interface builder, , preview pane looks should. on device that's story, below constraints image:

enter image description here

i've tried using aspect-ratio 1:1 constraint, image type set "aspect fill". issue image not retain square shape (76x76) , goes out of bounds:

enter image description here

if above , below picture, can see small border of parent 80x80 view there. image on otherhand, not listening constaints.

the problem while image view indeed square, image not. have 2 alternatives:

  • to keep whole image inside image view's bounds, change image view's content mode aspect fit (instead of aspect fill).

  • alternatively, set image view's "clips bounds" true. note mean edges of nonrectangular image lost.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -