UIViewContentMode UIViewContentMode Enum

Definition

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
UIViewContentModeUIViewContentMode
Attributes

Fields

Bottom Bottom 6

Aligns the content to the bottom of the view.

BottomLeft BottomLeft 11

Aligns the content to the bottom left of the view.

BottomRight BottomRight 12

Aligns the content to the bottom right side of the view.

Center Center 4

Centers the contents in the view

Left Left 7

Aligns the content to the left of the view.

Redraw Redraw 3

This forces a redraw when the Frame of an object changes.

Right Right 8

Aligns the content to the right of the view..

ScaleAspectFill 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.

ScaleAspectFit ScaleAspectFit 1

Scales the contents so that everything is visible, while preserving the aspect ration. Any areas that are not filled become transparent.

ScaleToFill ScaleToFill 0

Scales the contents to fit the new bounds, this might distort the contents.

Top Top 5

Aligns the content to the top of the view.

TopLeft TopLeft 9

Aligns the content to the top left of the view.

TopRight TopRight 10

Aligns the content to the top right 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}.

ValueBehavior
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.

Applies to