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,NSLog,CGPoint,CGRect,打印结构体,NSString)