标签:
// NSPoint\CGPoint(常用) NSSize\CGSize(常用) NSRect\CGRect(常用) NSRange
NSPoint p1 = NSMakePoint(10, 10);
CGPoint p2 = CGPointMake(10, 20); // 常用
NSSize s1 = NSMakeSize(50, 50);
CGSize s2 = CGSizeMake(50, 100); // 常用
CGPointZero == CGPointMake(0, 0); // CGPointZero表示原点(相应的有: CGSizeZero CGRectZero)
// CGRect的创建方式
CGRect r1 = CGRectMake(10, 10, 50, 50);
CGRect r2 = {{0, 0}, {100, 100}};
CGRectMake r3 = {p1, s1};
// 使用CGPointZero的前提是添加CoreGraphics框架
CGRect r4 = {CGPointZero, CGSizeMake(80, 90)};
// 将结构体转为字符串
NSString *str1 = NSStringFromPoint(p1);
NSString *str2 = NSStringFromSize(s1);
NSString *str3 = NSStringFromRect(r1);
//NSRange
NSRange r1 = NSMakeRange(3, 5);
NSString *str4 = @"As god name";
// 查找某个字符串在str中的范围
// 如果找不到,length = 0, location == NSNotFound == -1
NSRange range = [str rangeOfString:@"god"];
NSLog(@"location = %ld, length = %ld", range.location, range.length);
标签:
原文地址:http://www.cnblogs.com/lianfu/p/4643223.html