问题
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