ios开发之--CGRect/CGSize/CGPoint/CGVector/CGAffineTransform/UIEdgeInsets/UIOffset和NSString之间的转换

Posted 稻草人11223

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ios开发之--CGRect/CGSize/CGPoint/CGVector/CGAffineTransform/UIEdgeInsets/UIOffset和NSString之间的转换相关的知识,希望对你有一定的参考价值。

仅做记录,一个函数和字符串之间的互相转换

方法如下:

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);

例子:

结构体转字符串:

NSString *NSStringFromCGPoint(CGPoint point);  
NSString *NSStringFromCGVector(CGVector vector);  
NSString *NSStringFromCGSize(CGSize size);  
NSString *NSStringFromCGRect(CGRect rect);  
NSString *NSStringFromCGAffineTransform(CGAffineTransform transform);  
NSString *NSStringFromUIEdgeInsets(UIEdgeInsets insets);  
NSString *NSStringFromUIOffset(UIOffset offset); 

字符串转 结构体:

CGPoint CGPointFromString(NSString *string);  
CGVector CGVectorFromString(NSString *string);  
CGSize CGSizeFromString(NSString *string);  
CGRect CGRectFromString(NSString *string);   //我们在监听高度变化时需要用这个 ,获取键盘的frame 值,就是从一个 string类型中取出 CGRect!  
CGAffineTransform CGAffineTransformFromString(NSString *string);  
UIEdgeInsets UIEdgeInsetsFromString(NSString *string);//距离边界的距离,上左下右的顺序!  
UIOffset UIOffsetFromString(NSString *string);

 

以上是关于ios开发之--CGRect/CGSize/CGPoint/CGVector/CGAffineTransform/UIEdgeInsets/UIOffset和NSString之间的转换的主要内容,如果未能解决你的问题,请参考以下文章

李洪强iOS开发之 - 项目架构

iOS开发之手势识别汇总

IOS开发之代码之九宫格

iOS开发系列文章(持续转载中……) 感谢作者,直接连接到作者文章的

李洪强iOS开发之iOS学习方法收集

iOS开发之语音录制