CGPointMake explanation needed?
Asked Answered
A

1

5

could anyone explain to me what CGPointMake does please?

image.position = CGPointMake(80,200);
id go    = [MoveTo actionWithDuration:2 position:CGPointMake(190,460)];

for example this syntax above. I am not quite sure

Aurar answered 17/11, 2009 at 3:20 Comment(0)
K
14

It's an inline function that populates a CGPoint struct with the values you pass in.

Command-double-click CGPointMake in your code and you will be taken to the header, which shows the function:

CG_INLINE CGPoint
CGPointMake(CGFloat x, CGFloat y)
{
    CGPoint p; p.x = x; p.y = y; return p;
}
Kristeenkristel answered 17/11, 2009 at 3:25 Comment(4)
Please add some explanation.Floatstone
You're kidding, right? I'm not sure how much clearer I can be. What don't you get?Kristeenkristel
What ever you have given is copied straight away from the header and even we get this info from a code hint. What I expected in stackoverflow is how to decide the x and y values. what will be the minimum and maximum values for x and y values etc..Floatstone
A CGPoint is just a struct that stores the x and y values of an arbitrary two-dimensional point. How you use the point completely depends on what you're trying to do, and what context you're working in. There is no "minimum" or "maximum", apart from the limits of 64-bit FP values, because the struct is simply describing a point on a virtual cartesian plane. The Core Graphics and UIKit drawing APIs use CGPoint structures heavily, for all drawing and transformation functions, and they're occasionally used elsewhere where a point structure makes sense.Kristeenkristel

© 2022 - 2024 — McMap. All rights reserved.