Objective-C
NSRange (范围)
//////////范围结构体//////////
NSRange range = NSMakeRange(0, 10);
NSLog(@"位置:%ld 长度:%ld", range.location, range.length);
//输出: 位置:0 长度:10
//////////结构体转字符串//////////
NSString *rangeStr = NSStringFromRange(range);
NSLog(@"%@", rangeStr);
//输出: {0, 10}
CGPoint (点坐标)
//////////点坐标结构体//////////
CGPoint point = CGPointMake(0, 10);
CGPoint point0 = CGPointZero;
NSLog(@"X坐标:%.f Y坐标:%.f", point.x, point.y);
NSLog(@"X坐标:%.f Y坐标:%.f", point0.x, point0.y);
//输出: X坐标:0 Y坐标:10
//输出: X坐标:0 Y坐标:0
//////////结构体转字符串//////////
NSString *pointStr = NSStringFromCGPoint(point);
NSLog(@"%@", pointStr);
//输出: {0, 10}
CGSize (尺寸)
//////////尺寸结构体//////////
CGSize size = CGSizeMake(0, 10);
CGSize size0 = CGSizeZero;
NSLog(@"宽:%.f 高:%.f", size.width, size.height);
NSLog(@"宽:%.f 高:%.f", size0.width, size0.height);
//输出: 宽:0 高:10
//输出: 宽:0 高:0
//////////结构体转字符串//////////
NSString *sizeStr = NSStringFromCGSize(size);
NSLog(@"%@", sizeStr);
//输出: {0, 10}
CGRect (矩形)
//////////矩形结构体//////////
CGRect rect = CGRectMake(0, 10, 0, 10);
CGRect rect0 = CGRectZero;
CGRect rectNull = CGRectNull;
NSLog(@"X坐标:%.f Y坐标:%.f 宽:%.f 高:%.f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
NSLog(@"X坐标:%.f Y坐标:%.f 宽:%.f 高:%.f", rect0.origin.x, rect0.origin.y, rect0.size.width, rect0.size.height);
NSLog(@"X坐标:%.f Y坐标:%.f 宽:%.f 高:%.f", rectNull.origin.x, rectNull.origin.y, rectNull.size.width, rectNull.size.height);
//输出: X坐标:0 Y坐标:10 宽:0 高:10
//输出: X坐标:0 Y坐标:0 宽:0 高:0
//输出: X坐标:inf Y坐标:inf 宽:0 高:0
//////////结构体转字符串//////////
NSString *rectStr = NSStringFromCGRect(rect);
NSLog(@"%@", rectStr);
//输出: {{0, 10}, {0, 10}}
CGVector (矢量)
//////////矢量结构体//////////
CGVector vector = CGVectorMake(0, 10);
NSLog(@"xy:%.f dy:%.f", vector.dx, vector.dy);
//输出: xy:0 dy:10
//////////结构体转字符串//////////
NSString *vectorStr = NSStringFromCGVector(vector);
NSLog(@"%@", vectorStr);
//输出: {0, 10}
UIEdgeInsets (UI边缘)
//////////UI边缘结构体//////////
UIEdgeInsets edgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
NSLog(@"上:%.f 左:%.f 下:%.f 右:%.f", edgeInsets.top, edgeInsets.left, edgeInsets.bottom, edgeInsets.right);
//输出: 上:10 左:10 下:10 右:10
//////////结构体转字符串//////////
NSString *edgeInsetsStr = NSStringFromUIEdgeInsets(edgeInsets);
NSLog(@"%@", edgeInsetsStr);
//输出: {10, 10, 10, 10}
UIOffset (UI偏移)
//////////UI偏移结构体//////////
UIOffset offset = UIOffsetMake(10, 10);
NSLog(@"水平:%.f 竖直:%.f", offset.horizontal, offset.vertical);
//////////结构体转字符串//////////
NSString *offsetStr = NSStringFromUIOffset(offset);
NSLog(@"%@", offsetStr);
//输出: {10, 10}
网友评论