문제

I need a example of how to use CGPoint with a if statement to check the x and y coordinates

like something like this

if(CGPoint == (XCORDINATE, YCORDINATE)){
do stuff
}

and then i need a example of how to check the x and y coordinates on a label

if(mylabel == (xpoint, ypoint)){
do stuff
}

Thanks

도움이 되었습니까?

해결책

You get various CGPoints position for labels, using their properties. For example if you need to get the center point, get myLabel.center.

There are functions to create and compare points as described in CGGeometry Reference.

So for example you can do something like :

CGPoint testPoint = CGPointMake(50.0, 50.0);
if(CGPointEqualToPoint(testPoint, myLabel.center)) {
    // the two points equal
}

다른 팁

if( point.x == XCORDINATE && point.y == YCORNDINATE )
{
   // do stuff
}

If you want to check the coördinates of a label you simply do the above, and you get the location using:

CGPoint point = yourLabel.frame.origin;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top