[英]How to scale the image to fit the image view in ios?
I put an image in an image view in xcode and set "scale to fit" mode, but I find that the image doesn't fit the size of the image view. 我将图像放在xcode的图像视图中并设置“缩放到适合”模式,但我发现图像不符合图像视图的大小。 So how can I make the image to fit the size of the image view in ios?
那么如何使图像适合ios中图像视图的大小?
Below is the screenshot of storyboard. 以下是故事板的截图。
To do this in your storyboard, select your UIImageView
, open the Attributes Inspector, and select either "Aspect Fill" or "Aspect Fit" from the "Mode" drop down menu. 要在故事板中执行此操作,请选择
UIImageView
,打开“属性”检查器,然后从“模式”下拉菜单中选择“Aspect Fill”或“Aspect Fit”。
A couple of methods to play with: 有几种方法可以玩:
imageView.contentMode = UIViewContentMode.ScaleAspectFill
imageView.contentMode = UIViewContentMode.ScaleAspectFit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.