iOS Guides | Samples

CoreGraphics.CGRect Structure

Structure defining a rectangle in terms of location and size.

See Also: CGRect

Syntax

public struct CGRect : IEquatable<CGRect>

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 CGRect.ToDictionary method. You can also get an CGRect out a serialized dictionary by using the CGRect.TryParse method.

Requirements

Namespace: CoreGraphics
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0

The members of CoreGraphics.CGRect are listed below.

See Also: ValueType

Public Constructors

Initializes a CGRect structure from a rectangle and a size parameters.
Initializes a CGRect structure from a double precision floating point values, with potential truncation on 32 bit systems.
Initializes a CGRect structure from native floating point values.
Constructs a rectangle with the specified dimensions.

Public Fields

static readonly
EmptyCGRect.

Represents a CGRect structure with its properties left uninitialized.

Public Properties

[read-only]
Bottomnfloat.

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

Heightnfloat.

Gets or sets the height of this CGRect structure.

[read-only]
static
InfiniteCGRect. Gets an infinitely large rectangle.
[read-only]
IsEmptyBoolean.

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

[read-only]
Leftnfloat.

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

LocationCGPoint.

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

[read-only]
static
NullCGRect. Gets an invalid, or null, rectangle.
[read-only]
Rightnfloat.

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

SizeCGSize.

Gets or sets the size of this CGRect.

[read-only]
Topnfloat. The Y coordinate of the top of the rectangle.
Widthnfloat.

Gets or sets the width of this CGRect structure.

Xnfloat.

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

Ynfloat.

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

Public Methods

Contains(CGPoint) : Boolean

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

Contains(CGRect) : Boolean

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

Contains(Double, Double) : Boolean
true if the point [x, y] is within the rectangle.
Contains(nfloat, nfloat) : Boolean

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

Contains(Single, Single) : Boolean
Determines if the specified point is contained within this CGRect structure.
Equals(CGRect) : Boolean

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

override
Equals(Object) : Boolean

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

static
FromLTRB(nfloat, nfloat, nfloat, nfloat) : CGRect

Creates a CGRect structure with the specified edge locations.

override
GetHashCode() : Int32

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

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)

Enlarges this CGRect by the specified amount.

Inflate(Single, Single)
static
Inflate(CGRect, nfloat, nfloat) : CGRect

Creates and returns an enlarged copy of the specified CGRect structure. The copy is enlarged by the specified amount. The original CGRect structure remains unmodified.

Intersect(CGRect)

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

static
Intersect(CGRect, 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.

IntersectsWith(CGRect) : Boolean

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)

Adjusts the location of this rectangle by the specified amount.

Offset(Single, Single)
Adjusts the location of this rectangle by the specified amount.
ToDictionary() : NSDictionary
Serializes the state of the rectangle into an NSDictionary.
override
ToString() : String

Gets the y-coordinate of the top edge of this CGRect structure.

static
TryParse(NSDictionary, out CGRect) : Boolean
static
Union(CGRect, CGRect) : CGRect

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

Public Operators

static
Equality(CGRect, CGRect)

Tests whether two CGRect structures have equal location and size.

static
Inequality(CGRect, CGRect)Peforms a value comparison of two rectangles.
static
Conversion to System.Drawing.Rectangle(Explicit)Converts a CGRect to a Rectangle.
static
Conversion to System.Drawing.RectangleF(Explicit)Converts a CGRect to a RectangleF.
static
Conversion to CoreGraphics.CGRect(Implicit)Implicitly converts a Rectangle to a CGRect.
static
Conversion to CoreGraphics.CGRect(Implicit)Implicitly converts a RectangleF to a CGRect.