图像不适合UIImageView的框架 [英] Image is not fit to the frame of UIImageView

查看:77
本文介绍了图像不适合UIImageView的框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用界面生成器创建 UIImageView 。其框架尺寸为(320,67)。
我想在imageView上显示图像。我从网上获取图像。问题是来自网络的图像被拉伸到图像视图上显示...
这里我的代码

I am creating the UIImageView using interface Builder. Its frame size is (320,67). I want to display the image on the imageView. I am getting the image from the web. The problem is that the image get from web is stretched to display on the imageview... Here my code

NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.isco.com/webproductimages/appBnr/bnr1.jpg"]];
imageView.image = [UIImage imageWithData:imageData];

任何人都可以告诉我如何显示适合在imageView上显示的图像????

Can anyone tel me that how to display the image fit to display on imageView????

推荐答案

使用

imageView.contentMode = UIViewContentModeScaleAspectFill;

imageView.contentMode = UIViewContentModeScaleAspectFit;

第一个将填充框架,可能会切断部分图像。第二个将显示整个图像,可能使框架的区域打开。

The first one will fill the frame, possibly cutting off parts of your image. The second one will show the entire image, possibly leaving areas of the frame open.

这篇关于图像不适合UIImageView的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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