裁剪后如何适应相机的uiimage?

时间:2013-06-10 13:11:48

标签: iphone uiimageview

大家好,我正在从相机或照片库拍照。我有一个裁剪功能,将图像裁剪为1280 * 520像素。我有一个宽度为320 * 130像素的uiimageview。我面临的问题是它不完全适合uiimageview。我可以在顶部和底部看到空白区域。

enter image description here enter image description here enter image description here

1 个答案:

答案 0 :(得分:0)

示例代码:

[imageView setContentMode:UIViewContentModeTopLeft];
[imageView setClipsToBounds:YES];

内容模式:查看Documetation

typedef enum {
   UIViewContentModeScaleToFill,
   UIViewContentModeScaleAspectFit,
   UIViewContentModeScaleAspectFill,
   UIViewContentModeRedraw,
   UIViewContentModeCenter,
   UIViewContentModeTop,
   UIViewContentModeBottom,
   UIViewContentModeLeft,
   UIViewContentModeRight,
   UIViewContentModeTopLeft,
   UIViewContentModeTopRight,
   UIViewContentModeBottomLeft,
   UIViewContentModeBottomRight,
} UIViewContentMode;