标签:
1.NSRange
1 typedef struct _NSRange { 2 NSUInteger location; 3 NSUInteger length; 4 } NSRange;
location 位置
length 长度
2.NSPoint / CGPoint
1 struct CGPoint { 2 CGFloat x; 3 CGFloat y; 4 }; 5 typedef struct CGPoint CGPoint; 6 7 typedef CGPoint NSPoint;
x,y为坐标
3.NSSize / CGSize
1 struct CGSize { 2 CGFloat width; 3 CGFloat height; 4 }; 5 typedef struct CGSize CGSize; 6 7 typedef CGSize NSSize;
width 宽 height 高
4.NSRect / CGRect 矩形
1 struct CGRect { 2 CGPoint origin; 3 CGSize size; 4 }; 5 typedef struct CGRect CGRect; 6 7 typedef CGRect NSRect;
origin 为CGPoint型的点
size 为CGSize型的长度
范例
1 // NeXTSTEP 2 // CG 前缀 CoreGraphics 3 NSPoint point = {3,4}; 4 CGPoint point1 = CGPointMake(5, 6); 5 6 NSLog(@"%@",NSStringFromPoint(point)); 7 8 9 CGSize size1 = {3,4}; 10 CGSize size2 = CGSizeMake(3, 4); 11 12 NSLog(@"%@",NSStringFromSize(size1)); 13 // 矩形 14 CGRect rect = {point,size1}; 15 NSLog(@"%@",NSStringFromRect(rect));
标签:
原文地址:http://www.cnblogs.com/gwkiOS/p/4926610.html