Structure

CGSize

A structure that contains width and height values.

Declaration

struct CGSize

Overview

A CGSize structure is sometimes used to represent a distance vector, rather than a physical size. As a vector, its values can be negative. To normalize a CGRect structure so that its size is represented by positive values, call the standardized function.

Topics

Geometric Properties

var width: CGFloat

A width value.

var height: CGFloat

A height value.

Special Values

static var zero: CGSize

The size whose width and height are both zero.

init()

Creates a size with zero width and height.

Transforming Sizes

func applying(CGAffineTransform) -> CGSize

Returns the height and width resulting from a transformation of an existing height and width.

Alternate Representations

var dictionaryRepresentation: CFDictionary

Returns a dictionary representation of the specified size.

init?(dictionaryRepresentation: CFDictionary)

Creates a size from a canonical dictionary representation.

var debugDescription: String

A textual representation of the size’s dimensions.

var customMirror: Mirror

A representation of the size’s structure and display style for use in debugging.

var customPlaygroundQuickLook: PlaygroundQuickLook

A representation of the size for use in Playgrounds.

Deprecated

Comparing Sizes

func equalTo(CGSize) -> Bool

Returns whether two sizes are equal.

Initializers

init(width: Double, height: Double)

Creates a size with dimensions specified as floating-point values.

init(width: CGFloat, height: CGFloat)

Creates a size with dimensions specified as CGFloat values.

init(width: Int, height: Int)

Creates a size with dimensions specified as integer values.

Instance Methods

See Also

Geometric Data Types

struct CGFloat

The basic type for floating-point scalar values in Core Graphics and related frameworks.

struct CGPoint

A structure that contains a point in a two-dimensional coordinate system.

struct CGRect

A structure that contains the location and dimensions of a rectangle.

struct CGVector

A structure that contains a two-dimensional vector.

struct CGAffineTransform

An affine transformation matrix for use in drawing 2D graphics.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software