Uiviewcontentmode Yes UIView Uiimageview , UIView , UILabel Span style= "line-height:normal; font-family: "pingfang sc" "", UIButton set contentmode property to see the effect.
Through the test you can see that contentmode uiimageview function, for UIView UILabel UIButton
for uiview because its child view has already set its own frame , the position is fixed, so here contentmode The does not work.
for UILabel , UIButton , and did not, as expected, by setting a different Contentmode , while changing UILabel , UIButton The fill style for Chinese text or picture content.
So, for Contentmode The main exploration of the property is placed in the Uiimageview on.
Let's take a look at all the tests you get:
typedef Ns_enum (Nsinteger, Uiviewcontentmode) {
// default style picture fills the entire outline, does not zoom in or out proportionally, the picture may deform
Uiviewcontentmodescaletofill,
// picture is scaled up or down until the side lengths of the picture and contour are the same, and the picture must stretch but not deform
Uiviewcontentmodescaleaspectfit,
// picture is scaled up or down until the side lengths of the picture and contour are the same, and the picture must stretch but not deform
Uiviewcontentmodescaleaspectfill,
// when calling the setneedsdisplay method, the picture will be re-rendered, the following operation, the picture will not be stretched, not deformed
Uiviewcontentmoderedraw,
Uiviewcontentmodecenter,
Uiviewcontentmodetop,
Uiviewcontentmodebottom,
Uiviewcontentmodeleft,
Uiviewcontentmoderight,
Uiviewcontentmodetopleft,
Uiviewcontentmodetopright,
Uiviewcontentmodebottomleft,
Uiviewcontentmodebottomright,
};
Welcome to the great gods feel free, correct ~
IOS Uiviewcontentmode Detailed