如何在图像视图中将图像设置为适合屏幕 [英] How to set the image into fit screen in the image view

查看:170
本文介绍了如何在图像视图中将图像设置为适合屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iPhone开发的新手.我想在图像视图中显示图像的实际大小.我已经使用界面"构建器创建了图像视图并设置了属性.现在的问题是,我已设置为缩放以填充",然后图像将在全屏中拉伸.现在我要显示图像的实际大小,将在图像视图中显示.例如52X52尺寸的图像应在图像视图中以相同的尺寸显示.1200X1020尺寸的图像应适合图像视图的尺寸.因此根据图像的尺寸应适合图像视图,我想要图像小于图片视图的图片应保留其原始大小(不应拉伸以适合图片视图). 有任何可行的解决方案可以实现它,请指导我.

I am new to iphone development. I want to display the actual size of the image in image view. I have created image view by using Interface builder and set the properties. Now the problem is, I have set into "Scale to Fill", then the image will be stretched in the full screen. Now i want to display the actual size of the image will be displayed in image view. For example 52X52 size image should be displayed with the same size in the image view.The 1200X1020 size image should be fit to the size of the image view .So according the size of the image it should fit to image view and i want the image smaller than image view should retain its original size(It should not stretch to fit the image view). Is it any possible solution to achieve it, please guide me.

谢谢.

推荐答案

您将不得不自己检查UIImage的尺寸,然后在UIImageView上设置适当的属性:myImage.contentMode = UIViewContentModeCenter,等等

You're going to have to check the dimensions on the UIImage yourself and then set the proper property on the UIImageView: myImage.contentMode = UIViewContentModeCenter , etc

不同的内容模式: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆