CGRect Struct

Definition

Structure defining a rectangle in terms of location and size.

[System.Serializable]
public struct CGRect : IEquatable<CoreGraphics.CGRect>
[<System.Serializable>]
type CGRect = struct
Inheritance
CGRect
Attributes
Implements

Remarks

CGRects structures define a rectangle using floating point values of type NFloat and are defined using an initial location (X,Y) as well as a size (Width, Height).

You can save the CGRect into an NSDictionary by calling the ToDictionary() method. You can also get an CGRect out a serialized dictionary by using the TryParse(NSDictionary, CGRect) method.

Constructors

Name Description
CGRect(CGPoint, CGSize)

Initializes a CGRect structure from a rectangle and a size parameters.

CGRect(Double, Double, Double, Double)

Initializes a CGRect structure from a double precision floating point values, with potential truncation on 32 bit systems.

CGRect(NFloat, NFloat, NFloat, NFloat)
CGRect(Single, Single, Single, Single)

Constructs a rectangle with the specified dimensions.

Fields

Name Description
Empty

Represents a CGRect structure with its properties left uninitialized.

Properties

Name Description
Bottom

Gets the y-coordinate that is the sum of the Y and Height property values of this CGRect structure.

Height

Gets or sets the height of this CGRect structure.

Infinite

Gets an infinitely large rectangle.

IsEmpty

Tests whether all numeric properties of this CGRect have values of zero.

Left

Gets the x-coordinate of the left edge of this CGRect structure.

Location

Gets or sets the coordinates of the upper-left corner of this CGRect structure.

Null

Gets an invalid, or null, rectangle.

Right

Gets the x-coordinate that is the sum of X and Width property values of this CGRect structure.

Size

Gets or sets the size of this CGRect.

Top

The Y coordinate of the top of the rectangle.

Width

Gets or sets the width of this CGRect structure.

X

Gets or sets the x-coordinate of the upper-left corner of this CGRect structure.

Y

Gets or sets the y-coordinate of the upper-left corner of this CGRect structure.

Methods

Name Description
Contains(CGPoint)

Determines if the specified point is contained within this CGRect structure.

Contains(CGRect)

Determines if the rectangular region represented by rect is entirely contained within this CGRect structure.

Contains(Double, Double)

true if the point [x, y] is within the rectangle.

Contains(NFloat, NFloat)
Contains(Single, Single)

Determines if the specified point is contained within this CGRect structure.

Deconstruct(CGPoint, CGSize)
Deconstruct(NFloat, NFloat, NFloat, NFloat)
Equals(CGRect)

Tests whether rect is a CGRect structure with the same location and size of this CGRect structure.

Equals(Object)

Tests whether obj is a CGRect structure with the same location and size of this CGRect structure.

FromLTRB(NFloat, NFloat, NFloat, NFloat)
GetHashCode()

Returns the hash code for this CGRect structure. For information about the use of hash codes, see GetHashCode() .

Inflate(CGRect, NFloat, NFloat)
Inflate(CGSize)

Enlarges this CGRect by the specified amount.

Inflate(Double, Double)

Increases the size of the rectangle by adding the specified amounts along both directions of each axis.

Inflate(NFloat, NFloat)
Inflate(Single, Single)
Intersect(CGRect, CGRect)

Returns a third CGRect structure that represents the intersection of two other CGRect structures. If there is no intersection, an empty CGRect is returned.

Intersect(CGRect)

Replaces this CGRect with the intersection of itself and the specified CGRect.

IntersectsWith(CGRect)

Determines if this rectangle intersects with rect.

Offset(CGPoint)

Adjusts the location of this rectangle by the specified amount.

Offset(Double, Double)

Adjusts the location of this rectangle by the specified amount.

Offset(NFloat, NFloat)
Offset(Single, Single)

Adjusts the location of this rectangle by the specified amount.

ToCGRectDictionary()

Serializes a CGRect into a CGRectDictionary.

ToDictionary()

Serializes a CGRect into an NSDictionary.

ToString()

Converts this instance to a human readable string.

TryParse(NSDictionary, CGRect)

Attempts to parse the contents of an NSDictionary with a serialized CGRect into a CGRect.

Union(CGRect, CGRect)

Gets a CGRect structure that contains the union of two CGRect structures.

Operators

Name Description
Equality(CGRect, CGRect)
Explicit(CGRect to Rectangle)
Explicit(CGRect to RectangleF)
Implicit(Rectangle to CGRect)
Implicit(RectangleF to CGRect)
Inequality(CGRect, CGRect)

Extension Methods

Name Description
WithAspectRatio(CGRect, CGSize)
Divide(CGRect, NFloat, CGRectEdge, CGRect, CGRect)
GetMaxX(CGRect)
GetMaxY(CGRect)
GetMidX(CGRect)
GetMidY(CGRect)
GetMinX(CGRect)
GetMinY(CGRect)
Inset(CGRect, NFloat, NFloat)
Integral(CGRect)
IsInfinite(CGRect)
IsNull(CGRect)
Standardize(CGRect)
UnionWith(CGRect, CGRect)

Applies to