The general method of Objective-c geometry class

Source: Internet
Author: User

Cggeometry reference defines geometry and functionality for easy operation. A point cgpoint in the data structure is represented in a two-dimensional coordinate system. The location and size of the data structure CGRect represents a rectangle. The size of the data structure cgsize represents the width and height.

1. Create a geometric primitive value

Cgpoint Cgpointmake (cgpoint a,cgpoint B)

Returns a specified coordinate point

CGRect CGRectMake (cgfloat x,cgfloat y,cgfloat width,cgfloat height)

Creates a rectangle based on the specified coordinates and size

Cgsize cgsizemake (cgfloat width,cgfloat height)

Creates a cgsize based on the specified length width

2. Modify the Rectangle

CGRect Cgrectinset (cgrect rect,cgfloat dx,cgfloat dy)

Returns a rectangle larger or smaller than the original rectangle, but the center point is the same

CGRect cgrectintegral (CGRect A)

Converts the value of rectangle A to an integer to get a minimum rectangle

CGRect cgrectintersection: (CGRect a,cgrect B)

Gets the rectangle where two rectangles intersect, no intersect returns NULL, detects with Cgrectisnull

3. Compare values

BOOL Cgpointequaltopoint (cgpoint a,cgpoint B)

Returns whether two points are equal

BOOL Cgsizeequaltosize (cgsize a,cgsize B)

Cgsizeab is equal

BOOL Cgrectequaltorect (CGRect a,cgrect B)

Whether the position size of the rectangle AB is equal

BOOL Cgrectintersectsrect (CGRect a,cgrect B)

Whether the rectangle AB intersects, can be used to determine whether the Genie left the screen

4. Check

BOOL Cgrectcontainspoint (CGRect A, Cgpoint B)

Detects whether the rectangle a contains the specified point B

BOOL Cgrectcontainsrect (CGRect a,cgrect B)

Detects if rectangle A contains a rectangle b

5. Get the maximum, middle and minimum values

CGFloat Cgrectgetminx (CGRect A)

Gets the minimum value of the x-coordinate of the rectangle

CGFloat cgrectgetminy (CGRect A)

Gets the minimum value of the y-coordinate of the rectangle

CGFloat cgrectgetmidx (CGRect A)

Gets the middle value of the rectangle's X coordinate

CGFloat Cgrectgetmidy (CGRect A)

Gets the middle value of the y-coordinate of the rectangle

CGFloat Cgrectgetmaxx (CGRect A)

Gets the maximum value of the rectangle's x-coordinate

CGFloat Cgrectgetmaxy (CGRect A)

Gets the maximum value of the y-coordinate of the rectangle

6. Get high and wide

CGFloat cgrectgetheight (CGRect A)

Gets the height of the rectangle a

CGFloat cgrectgetwidth (CGRect A)

Gets the width of the rectangle a

7. Check whether the rectangle exists or infinity

BOOL Cgrectisempty (CGRect A)

Whether rectangle A is long and wide is 0, or is a null

BOOL Cgrectisnull (CGRect A)

Whether rectangle A is null

BOOL Cgrectisinfinite (CGRect A)

Whether rectangle A is infinite, no boundary

The general method of Objective-c geometry class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.