如题。
图片大小不固定。但是我想让图片在容器里面保持原本的尺寸,正常显示。
------补充------
如要使用原尺寸
使用下面的
UIViewContentModeCenter,
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
选择UIViewContentModeScaleToFill
, UIViewContentModeScaleAspectFit
,UIViewContentModeScaleAspectFill
时
如果容器frame
和UIImage
的尺寸不合,
都会进行不同形式的拉伸
下面是效果,用的UIViewContentModeCenter
//所有代码
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bbbbb"]];
imageView.frame = self.view.frame;
imageView.contentMode = UIViewContentModeCenter;
[self.view addSubview:imageView];
没问题啊