Foundation-02 _ struct _ point, size, rect

Source: Internet
Author: User

Cgfloat is double cgpoint and nspoint, but cgpoint is generally used in development, because cgpoint is cross-platform Cgpoint and nspoint indicate a point. The most common method is cgpointmake (x, y) Cgpoint p1 = cgpointmake (x, y ); Nspoint p1 = cgpointmake (x, y ); You can also use cgpoint P = nsmakepoint (x, y); nspoint P = nsmakepoint (x, y ); Nssize is equivalent to cgsize. There are two parameters, one being long and the other being wide, indicating that the UI element size is created using nsmakesize (W, h) cgsizemake (W, H) nssize S1 = cgsizemake (100,100); nssize S2 = nsmakesize (100,100); cgsize S3 = nsmakesize (100,100 ); Nsrect is equivalent to cgrect. It indicates that the location and size have two parameters: (cgpoint, cgsize) cgpoint corresponds to the origin cgsize parameter size cgrect R1 = cgrectmake (,); other methods to create cgrect: cgrect r = {}, {}}; cgrect r = {p1, p2 }; Converts a struct to a string.   Nsstringfromrange (<# nsange range #>) converts nspoint or cgpoint to a string: nsstringfrompoint (<# nspoint apoint #>) to convert nssize or cgsize to a string: nsstringfromsize (<# nssize asize #>) converts nsrect or cgrect to a string: nsstringfromrect (<# nsrect arect #>) origin: cgpointmake (0, 0) is equivalent Cgpointzero Cgpointzero is a constant that represents the coordinate origin. Cgsizezero is equivalent to cgsizemake (0, 0 ); Cgsizezero is a constant, representing the size of 0 Cgrectzero is equivalent to cgrectmake (0, 0, 0, 0 ); Cgrectzero is a constant that represents the UI element with a size of 0 at the coordinate origin. Compare whether the two points are the same: Cgpointequaltopoint (point1, point2 ); The return value is bool to compare whether the two dimensions are the same: Cgsizeeuqaltosize (size1, size2 ); The returned value is whether the bool comparison position and size are the same: Cgrectequaltorect (rect1, rect2 ); The return value is bool to determine whether a rectangle contains a vertex: Cgrectcontainspoint (rect, point ); The returned value is the coordinate origin in bool iOS, which is in the upper left corner:

    

Foundation-02 _ struct _ point, size, rect

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.