Search code examples
objective-cuiimageviewaspect-ratio

iOS Make ImageView Align to Top Corner


I'm trying to set a background that fits in both portrait and landscape. Problem I have is there is a logo in the top right of the image. The size of the image is 2048 x 2048.

In portrait mode it's fine but when in landscape I lose the logo as it clips to all sides.

I'm using auto layout in Interface Builder and have set all constraints to 0 and view to aspect fill.

Is it possible for the image view to pin the top right corner to the top right of the screen and for it to clip only on the left and the bottom?


Solution

  • how about setting your background ContentMode to Top Right, and adjust Layouting Constrains to view bounds ? this image will not get resized and logo will always appear.

    instead u can get logo separately and place your image without logo, and just set logo to snap to right and top borders