本文主要是介绍iOS CGRect CGPoint NSRange等结构体的NSLog打印输出,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
iOS的UIKit里提供了UIGeometry.h内有各结构体转换成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);
#ifndef FOUNDATION_HAS_DIRECTIONAL_GEOMETRY
#if UIKIT_HAS_UIFOUNDATION_SYMBOLS
UIKIT_EXTERN NSString *NSStringFromDirectionalEdgeInsets(NSDirectionalEdgeInsets insets) API_AVAILABLE(ios(11.0),tvos(11.0),watchos(4.0));
#endif // UIKIT_HAS_UIFOUNDATION_SYMBOLS
#endif // FOUNDATION_HAS_DIRECTIONAL_GEOMETRY
UIKIT_EXTERN NSString *NSStringFromUIOffset(UIOffset offset);
比如打印要打印一个页面上的point:
CGPoint testPt = CGPointMake(1.f, 1.f);
NSLog(@"%@", NSStringFromCGPoint(testPt));
这篇关于iOS CGRect CGPoint NSRange等结构体的NSLog打印输出的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!