CGPoint,CGSize,CGRect转NSString以及CGRect的一些便捷实用方法

时间:2023-03-08 16:52:46

打印代码小技巧

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 *NSStringFromDirectionalEdgeInsets(NSDirectionalEdgeInsets insets) API_AVAILABLE(ios(11.0),tvos(11.0),watchos(4.0));
UIKIT_EXTERN NSString *NSStringFromUIOffset(UIOffset offset);
 CGRect rect =  CGRectMake(50, 100, 80, 80);
CGRectGetMinX(rect);//返回矩形最左边的x
CGRectGetMidX(rect);//返回矩形中中心点x
CGRectGetMaxX(rect);//返回矩形最右边的x CGRectGetMinY(rect);//返回矩形最上边的y
CGRectGetMidY(rect);//返回矩形中中心点y
CGRectGetMaxY(rect);//返回矩形最下边的y CGRectGetWidth(rect);//返回矩形的宽度
CGRectGetHeight(rect);//返回矩形的高度
    CGRect rect =  CGRectMake(50, 100, 80, 80);
NSLog(@"-----:%f %f %f",CGRectGetMinX(rect),CGRectGetMidX(rect),CGRectGetMaxX(rect));
NSLog(@"-----:%f %f %f ",CGRectGetMinY(rect),CGRectGetMidY(rect),CGRectGetWidth(rect));
NSLog(@"-----:%f %f ",CGRectGetWidth(rect),CGRectGetHeight(rect));
//130.000000 180.000000 90.000000 140.000000
//50.000000 100.000000 80.000000 80.000000