Conversion between--cgrect/cgsize/cgpoint/cgvector/cgaffinetransform/uiedgeinsets/uioffset and NSString for iOS development

Source: Internet
Author: User

Just record, a function and a string convert each other

Here's how:

Uikit_extern NSString *Nsstringfromcgpoint (Cgpoint point); Uikit_extern NSString*nsstringfromcgvector (cgvector vector); Uikit_extern NSString*nsstringfromcgsize (cgsize size); Uikit_extern NSString*nsstringfromcgrect (CGRect rect); Uikit_extern NSString*Nsstringfromcgaffinetransform (Cgaffinetransform transform); Uikit_extern NSString*nsstringfromuiedgeinsets (uiedgeinsets insets); Uikit_extern NSString*Nsstringfromuioffset (uioffset offset); Uikit_extern cgpoint cgpointfromstring (nsstring*string); Uikit_extern cgvector cgvectorfromstring (nsstring*string); Uikit_extern cgsize cgsizefromstring (nsstring*string); Uikit_extern cgrect cgrectfromstring (nsstring*string); Uikit_extern cgaffinetransform cgaffinetransformfromstring (nsstring*string); Uikit_extern uiedgeinsets uiedgeinsetsfromstring (nsstring*string); Uikit_extern uioffset uioffsetfromstring (nsstring*string);

Example:

struct to string:

NSString *nsstringfromcgpoint (cgpoint point);   *nsstringfromcgvector (cgvector vector);   *nsstringfromcgsize (cgsize size);   *nsstringfromcgrect (cgrect rect);   *Nsstringfromcgaffinetransform (cgaffinetransform transform);   *nsstringfromuiedgeinsets (uiedgeinsets insets);  

String to struct body:

 cgpoint cgpointfromstring (nsstring *string    ); Cgvector cgvectorfromstring (nsstring  *string    *string    );   CGRect cgrectfromstring (nsstring  *string ); //   We need this when we listen to the height change, get the frame value of the keyboard, and take it out of a string type cgrect!  cgaffinetransform cgaffinetransformfromstring (nsstring *string   *string ); //  distance from the boundary, upper left and bottom right order!  uioffset uioffsetfromstring (nsstring *string ); 

Conversion between--cgrect/cgsize/cgpoint/cgvector/cgaffinetransform/uiedgeinsets/uioffset and NSString for iOS development

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.