typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
};
可以用XIB拖个imageView进行显示,改变mode观察显示的变化
UIViewContentModeScaleToFill,
会填充整个imageView的frame,所以图片会变形
UIViewContentModeScaleAspectFit,
会按图片的比例进行显示,imageView会有部分空白// contents scaled to fit with fixed aspect. remainder is transparent
UIViewContentModeScaleAspectFill,
会按图片的比例进行显示,图片可能大于imageView的frame,超出的部分会被clipped。
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
会调用这个方法-setNeedsDisplay
UIViewContentModeCenter,
图片保持原有大小 ,调整位置显示为中心显示
// contents remain same size. positioned adjusted.
UIViewContentModeTop,
如上,图片保持原有大小,调整位置为靠上显示
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
};
可以用XIB拖个imageView进行显示,改变mode观察显示的变化