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

查看:16
本文介绍了图像不适合 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天全站免登陆