CGRect myImageRect = CGRectMake (0.0f, 0.0f, 320.0f, 109.0f);
Why CGRectMake can be so used, and many other things need to use [CXXXObject alloc] in such a way?
Reply:
CGRect is a C struct, not an objective c object, objects need only objective in such a way alloc
Look at the definition of
CGRectMakeCG_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;
}
In fact, an inline function to generate this structure
CGRect
No comments:
Post a Comment