图像不适合 UIImageView 的框架

Image is not fit to the frame of UIImageView(图像不适合 UIImageView 的框架)
本文介绍了图像不适合 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 的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)