问题描述:

How Do I Compare CGPoint's

I Tried This

if (imageView.center > invisibleimage.center) {

}

网友答案:

well think about it, what makes a center bigger than another center? that doesnt make sense. what you probably want is

if (imageView.center.x > invisibleimage.center.x && 
    imageView.center.y > invisibleimage.center.y)
网友答案:

If you want compare equal,use this function.

CGPointEqualToPoint

Document

Returns whether two points are equal.

true if the two specified points are the same; otherwise, false.

If you want to compare greater or less,you have to define what is "Greater" like Fonix said

网友答案:

CGCenter is a struct which comprises of

CGCenter {
float x,
float y.
}

Only comparable condition for CGCenter is that are two centers equal as in their x and y are equal, that is done by CGPointEqualToPoint or else you can compare their x and y as in

if(myLabel.center.x > myOtherLabel.center.x)
OR if(myLabel.center.y > myOtherLabel.center.y)

Hope this helps you

相关阅读:
Top