Why scale to fill give bigger image than UIImageVIew size? (using swift)

前端 未结 5 1084
天涯浪人
天涯浪人 2021-01-31 18:23

I\'m trying to showing a list of place name, including it\'s photo using PFQueryTableViewController. It\'s included in ParseUI SDK from parse.com

I have man

5条回答
  •  礼貌的吻别
    2021-01-31 18:54

    With content mode set to Aspect Fill, try setting clips to bounds to true as well, reason being the content mode aspect fill keeps on filling the frame of the image view till the frame is fully filled with content also keeping the aspect ratio intact. In the process of filling the container with image maintaining aspect ratio, either vertical or horizontal frame is fully filled, and the filling is continued till the other (if horizontal than vertical or vise versa) portion is fully filled. Thus the first filled portion either across vertical or horizontal will go out of bounds and the content will be visible outside the frame of the image view. To clip the extra content we need to clip the extra portion using imageView's clipsToBounds property set to true

    cell.photo.contentMode = UIViewContentMode.ScaleAspectFill
    cell.photo.clipsToBounds = true
    

提交回复
热议问题