Contents

contentsGravity

A constant that specifies how the layer’s contents are positioned or scaled within its bounds.

Declaration

var contentsGravity: CALayerContentsGravity { get set }

Discussion

The possible values for this property are listed in Contents Gravity Values.

The default value of this property is resize.

Figure 1 shows four examples of the effect of setting different values for a layer’s contentsGravity property.

[Image]

  1. Contents gravity is resize - the default

  2. Contents gravity is center

  3. Contents gravity is contentsAreFlipped() ? top : bottom

  4. Contents gravity is contentsAreFlipped() ? bottomLeft : topLeft

See Also

Modifying the layer’s appearance