IOS:一种在图像视图中设置图像的快速方法 [英] IOS: a quickly way to set an image in a imageview
本文介绍了IOS:一种在图像视图中设置图像的快速方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个 77x77 的图像视图并且我想在这个图像视图中调整一个 UIImage,这可能吗?在示例中,我想在此图像视图中设置大小为 300x200 的图像,有没有办法在此图像视图(77x77)中调整此图像?谢谢
If I have an imageview of 77x77 and I want to adapt an UIImage in this imageview, is it possible? at the example I want set in this imageview an image with a size of 300x200, is there a way to adapt this image inside this imageview (77x77) ?? thanks
推荐答案
Yes, myImageView.contentMode = UIViewContentModeScaleAspectFit;
该属性继承自UIView.
UIViewContentMode
UIViewContentMode
指定视图在其大小发生变化时如何调整其内容.
Specifies how a view adjusts its content when its size changes.
typedef enum {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit,
UIViewContentModeScaleAspectFill,
UIViewContentModeRedraw,
UIViewContentModeCenter,
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
} UIViewContentMode;
这篇关于IOS:一种在图像视图中设置图像的快速方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文