IOS: a quickly way to set an image in a imageview

怎甘沉沦 提交于 2019-12-12 06:27:57

问题


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


回答1:


Yes, myImageView.contentMode = UIViewContentModeScaleAspectFit;

The property is inherited from UIView.

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;


来源:https://stackoverflow.com/questions/11317764/ios-a-quickly-way-to-set-an-image-in-a-imageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!