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:
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:
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
Post a Comment