CGRectMake(1, 3, 大小):
CGRectMake(1, 3, size.width, size.heigh)
CGRectMake(pointB, 大小):
CGRectMake(pointB.x, pointB.y, size.width, size.height)
CGRectMake(pointB, size.width, size.height):
CGRectMake(pointB.x, pointB.y, size.width, size.height)
CGRect 看起来像这样:
struct CGRect {
CGPoint origin;
CGSize size;
};
typedef struct CGRect CGRect;
CGPoint 和 CGSize 看起来像这样:
struct CGPoint {
CGFloat x;
CGFloat y;
};
typedef struct CGPoint CGPoint;
struct CGSize {
CGFloat width;
CGFloat height;
};
typedef struct CGSize CGSize;
CGRectMake 是以下函数:
CG_INLINE CGRect
CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
CGRect rect;
rect.origin.x = x;
rect.origin.y = y;
rect.size.width = width;
rect.size.height = height;
return rect;
}
所以而不是:
CGRect r = CGRectMake(pointB.x, pointB.y, size.width, size.height)
你可以简单地写:
CGRect r;
r.origin = pointB;
r.size = size;
如果您想创建自己的 CGRectMake,请随意这样做:
CG_INLINE CGRect
MyPrivateCGRectMake(CGPoint p, CGSize s)
{
CGRect rect;
rect.origin = p;
rect.size = s;
return rect;
}
但是您无法更改已经存在的函数接受哪些参数。