UIViewContentMode Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An enumeration indicating how the cached bitmap of a view must be rendered when the view's bounds change.
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.WatchOS, ObjCRuntime.PlatformArchitecture.All, null)]
public enum UIViewContentMode
type UIViewContentMode =
- Inheritance
-
UIViewContentMode
- Attributes
Fields
Name | Value | Description |
---|---|---|
ScaleToFill | 0 | Scales the contents to fit the new bounds, this might distort the contents. |
ScaleAspectFit | 1 | Scales the contents so that everything is visible, while preserving the aspect ration. Any areas that are not filled become transparent. |
ScaleAspectFill | 2 | Scales the contents to fill the new bounaries of the view, while preserving the aspect ratio. This means that the contents might be clipped. |
Redraw | 3 | This forces a redraw when the Frame of an object changes. |
Center | 4 | Centers the contents in the view |
Top | 5 | Aligns the content to the top of the view. |
Bottom | 6 | Aligns the content to the bottom of the view. |
Left | 7 | Aligns the content to the left of the view. |
Right | 8 | Aligns the content to the right of the view.. |
TopLeft | 9 | Aligns the content to the top left of the view. |
TopRight | 10 | Aligns the content to the top right of the view. |
BottomLeft | 11 | Aligns the content to the bottom left of the view. |
BottomRight | 12 | Aligns the content to the bottom right side of the view. |
Remarks
The contents of the UIView are cached in a bitmap, the values in this enumeration determine what happens to a view when the bounds of that view change. With these you can control whether the bitmap is stretched or whether the view is redrawn.
The following table shows the behavior as it works placing this {638, 475} image in a UIImageView of size {280, 100}.
Value | Behavior | |
---|---|---|
Bottom | Aligns the content to the bottom of the view. | |
BottomLeft | Aligns the content to the bottom left of the view. | |
BottomLeft | Aligns the content to the bottom left of the view. | |
BottomLeft | Aligns the content to the bottom left of the view. | |
BottomLeft | Aligns the content to the bottom left of the view. | |
BottomLeft | Aligns the content to the bottom left of the view. | |
BottomRight | Aligns the content to the bottom right of the view. | |
Center | Center the content in the view. | |
Left | Aligns the content to the left of the view. | |
Redraw | Forces a redraw when the Frame of an object changes. | |
Right | Aligns the content to the right of the view. | |
ScaleAspectFill | Scales the contents to fill the new bounaries of the view, while preserving the aspect ratio. This means that the contents might be clipped. | |
ScaleAspectFit | Scales the contents so that everything is visible, while preserving the aspect ratio. Any areas that are not filled become transparent. (In the image, the P:UIKit.UIImage.BackgroundColor was set to black to emphasize the scaling behavior.) | |
ScaleToFill | Scales the contents to fit the new bounds, this might distort the contents. | |
Top | Aligns the content to the top of the view. | |
TopLeft | Aligns the content to the top left of the view. | |
TopRight | Aligns the content to the top right of the view. |