1.CGRectOffset使用从源CGRect偏移的原点来创建矩形
float offset = 25.0;
CGRect r1 = CGRectMake(100, 100, 100, 100);
CGRect r2 = CGRectOffset(r1, offset, offset);
2.CGRectIntersectsRect允许我们确定两个矩形是否相交
float offset = 25.0;
CGRect r1 = CGRectMake(100, 100, 100, 100);
CGRect r2 = CGRectMake(150, 150, 100, 100);
if (CGRectIntersectsRect(r1, r2))
{
NSLog(@"intersecting");
}
3.NSStringFromCGRect可以用来把CGRect显示到控制台
CGRect r1 = CGRectMake(100, 100, 100, 100);
NSLog(@"rect:@%",NSStringFromCGRect(r1));
同样,CGRectFromString允许我们根据一个字符串创建一个CGRect:
NSString *r = @"{0,0},{100,100}";
CGRect r1 = CGRectFromString(r);
float offset = 25.0;
CGRect r1 = CGRectMake(100, 100, 100, 100);
CGRect r2 = CGRectOffset(r1, offset, offset);
2.CGRectIntersectsRect允许我们确定两个矩形是否相交
float offset = 25.0;
CGRect r1 = CGRectMake(100, 100, 100, 100);
CGRect r2 = CGRectMake(150, 150, 100, 100);
if (CGRectIntersectsRect(r1, r2))
{
NSLog(@"intersecting");
}
3.NSStringFromCGRect可以用来把CGRect显示到控制台
CGRect r1 = CGRectMake(100, 100, 100, 100);
NSLog(@"rect:@%",NSStringFromCGRect(r1));
同样,CGRectFromString允许我们根据一个字符串创建一个CGRect:
NSString *r = @"{0,0},{100,100}";
CGRect r1 = CGRectFromString(r);