iOS Dev (29) UIViewContentMode
-
UIViewContentMode 都有哪些值:
typedef NS_ENUM(NSInteger, UIViewContentMode) { UIViewContentModeScaleToFill, UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped. UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay) UIViewContentModeCenter, // contents remain same size. positioned adjusted. UIViewContentModeTop, UIViewContentModeBottom, UIViewContentModeLeft, UIViewContentModeRight, UIViewContentModeTopLeft, UIViewContentModeTopRight, UIViewContentModeBottomLeft, UIViewContentModeBottomRight, };
默認值是 0,也就是:
UIViewContentModeScaleToFill
一個個來理解下吧:
- UIViewContentModeScaleToFill:表示完全填充在 frame 裡。
- UIViewContentModeScaleAspectFit:保持比例,都在 frame 內。
- UIViewContentModeScaleAspectFill:保持比例,填滿但 frame 外也有。
- UIViewContentModeRedraw:啥意思我還不懂。
其他的是相似的,好理解:
- UIViewContentModeCenter:這個 image 的中心與 frame 的中心重合。
- UIViewContentModeTop:這個 image 的上邊緣與 frame 的上邊緣重合。
- UIViewContentModeBottom:這個 image 的下邊緣與 frame 的下邊緣重合。
- UIViewContentModeLeft:這個 image 的左邊緣與 frame 的左邊緣重合。
- UIViewContentModeRight:這個 image 的右邊緣與 frame 的右邊緣重合。
- UIViewContentModeTopLeft:類似。
- UIViewContentModeTopRight:類似。
- UIViewContentModeBottomLeft:類似。
- UIViewContentModeBottomRight:類似。
–
轉載請註明來自:https://blog.csdn.net/prevention