UIViewContentMode解释

来源:互联网 发布:淘宝确认收货几天 编辑:程序博客网 时间:2024/05/25 19:57
UIViewContentmode的含义
UIView有个UIViewContentMode类型的属性contentMode,可以通过它来修改视图的内容显示模式。
1)UIViewContentModeScaleToFill:
个人理解:根据视图的比例去拉伸图片内容 充满整个视图;
官方解释:The option to scale the content to fit the size of itself by changing the aspect ratio of the content if necessary.

2)UIViewContentModeScaleAspectFit
个人解释:等比例对视图内容进行缩放,以适应视图。视图内容显示在视图中间。
官方解释:The option to scale the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.

3)UIViewContentModeScaleAspectFill
个人解释:视图内容等比例填满整个视图,超出视图而没有超出屏幕范围的也是会显示在屏幕上。只有在视图内容超出屏幕的时候,才会对视图内容的超出屏幕部分修剪。
官方的解释:The option to scale the content to fill the size of the view. Some portion of the content may be clipped to fill the view’s bounds.
ps:个人感觉官方的这个解释不是太清楚,我在使用的时候,发现若view 的frame小于screen的frame view里面的图片在此属性下超出view但不超出screen的部分是不会被剪掉的。(我做的时候是这样的,大家可以试试)

4)UIViewContentModeRedraw  
个人解释:

5)UIViewContentModeCenter
个人解释:视图内容的center和视图的重合,当视图内容frame大于视图frame时,也会显示在屏幕上。
官方解释:The option to center the content in the view’s bounds, keeping the proportions the same.

6)UIViewContentModeTop
UIViewContentModeTopLeft
UIViewContentModeTopRight
个人解释:视图内容分别在视图内顶部居中显示,顶部左顶点重合显示和右顶点重合显示,当视图内容frame大于视图frame时,也会显示在屏幕上。

官方解释:
The option to center the content aligned at the top in the view’s bounds.
The option to align the content in the top-left corner of the view.
 The option to align the content in the top-right corner of the view.
 
7)UIViewContentModeBottom
UIViewContentModeBottomLeft
UIViewContentModeBottomRight 
个人解释:视图内容分别在视图内底部居中显示,底部左顶点重合显示和右顶点重合显示,当视图内容frame大于视图frame时,也会显示在屏幕上。
官方解释:
The option to center the content aligned at the bottom in the view’s bounds
The option to align the content in the bottom-left corner of the view.
The option to align the content in the bottom-right corner of the view.

8)UIViewContentModeLeft
  UIViewContentModeRight
个人解释:视图内容左边界中点和视图左边界中点重合显示和视图内容右边界中点和视图右边界中点重合显示,当视图内容frame大于视图frame时,也会显示在屏幕上。
官方解释:
The option to align the content on the left of the view
The option to align the content on the right of the view.

ps:只是自己看到别人写的和自己根据自己实际操作总结出来的。可能有不足或不对的地方,使用前自己最好验证下。


0 0