Instance Property

frame

The frame rectangle, which describes the view’s location and size in its superview’s coordinate system.

Declaration

var frame: CGRect { get set }

Discussion

This rectangle defines the size and position of the view in its superview’s coordinate system. You use this rectangle during layout operations to size and position the view. Setting this property changes the point specified by the center property and the size in the bounds rectangle accordingly. The coordinates of the frame rectangle are always specified in points.

Changing the frame rectangle automatically redisplays the receiver without invoking the draw(_:) method. If you want the draw(_:) method invoked when the frame rectangle changes, set the contentMode property to redraw.

Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.

See Also

Related Symbols

var center: CGPoint

The center of the frame.

var bounds: CGRect

The bounds rectangle, which describes the view’s location and size in its own coordinate system.

var transform: CGAffineTransform

Specifies the transform applied to the receiver, relative to the center of its bounds.