Mary Torh
Mary Torh

Reputation: 31

UIView position detect

How can I detect if my UIView frame is equal to myFrame?

I need something like:

CGRect myFrame;
myFrame = CGRectMake(0, -51, 320, 50);
if(view.frame == myFrame) 
{
    NSLog(@"Congrats");
}

Upvotes: 1

Views: 123

Answers (2)

Girish
Girish

Reputation: 4712

CGRectEquatToRect is a function which checks the equality of two frames, just needs to pass the frames of two views whose equality you want to check. It returns the boolean result. Returns true, if two frames are equal else false.

Upvotes: 0

Darren
Darren

Reputation: 10129

You could use

CGRect myFrame = CGRectMake(0, -51, 320, 50);
if (CGRectEqualToRect(myFrame,view.frame))
{
    NSLog(@"Congrats");
}

See the apple docs on CGGeometry Reference for more info: http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Reference/CGGeometry/Reference/reference.html.

Upvotes: 2

Related Questions