UIViewContentModeScaleAspectFill not clipping

Solution 1:

Can you try setting clip to bounds

[_photoview setClipsToBounds:YES];

Or directly in your Storyboard / Xib if you can :

enter image description here

Solution 2:

If you want to expand your knowledge there is a really good article on how the iOS UIView stack is rendered. There is also a more in-depth article about the whole drawing pipeline.

In summary:

  1. Rasterisation - All the view's content is rasterised (drawn or a offscreen pixel buffer) in coordinate space of the View's bounds. This could be image data or custom drawing (i.e. drawRect:) but subview content. This rasterisation takes into account the contentMode property.

    Anything outside of a view’s bounds is discarded.

  2. Composition - The results are composited (drawn on top of each other) from subview to superviews. This uses the frame property of the subview.

    If the clipsToBounds property is YES on the superview then it will discard subview content outside of its bounds.

Solution 3:

had the same problem and it was resolved by ticking "Clip Subviews".

The image was showing up properly for all views (3.5,4,4.7,5.5,ipad) in storyboard preview but not in the simulator.

After I ticked "Clip Subviews" the problem was resolved. :)