CGFloat, CGPoint, CGSize, CGRect, and CGRectZero related to plotting in ios development

Source: Internet
Author: User

CGFloat: indicates a floating point.

CGPoint: indicates a vertex.

CGsize: indicates a rectangle with only the height and width.

CGRect: indicates the position of a rectangle with the origin.

CGRectZero: This constant is used when the height is zero, the width is zero, and the origin position is zero. You need to create a border but you are not sure about the border size and position.

CGPointMake, CGRectMake, and CGSizeMake are used for initialization.

NSStringFromPoint, NSStringFromRect, and NSStringFromSize are used to convert Poing, rect, and size into strings.


Code:


CGFloat f = 1.2f;
CGPoint point = CGPointMake (1.2F, 2.3F );
CGRect cgrect = CGRectMake (1.2f, 2.3, 4.5, 5.6 );
CGSize size = CGSizeMake (2.3, 3.2 );
NSLog (@ "float is % f", f );
NSLog (@ "point is % @", NSStringFromPoint (point ));
NSLog (@ "cgrect is % @", NSStringFromRect (cgrect ));
NSLog (@ "size is % @", NSStringFromSize (size ));

Result


15:29:25. 522 test [1734: 303] float is 1.200000
15:29:25. 523 test [1734: 303] point is {1.2000000476837158, 2.2999999523162842}
15:29:25. 523 test [1734: 303] cgrect is {1.2000000476837158, 2.2999999999999998}, {4.5, 5.5999999999999996 }}
15:29:25. 523 test [1734: 303] size is {2.2999999999999998, 3.2000000000000002}

 

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.