Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing two CGRects

I needed to check wether the frame of my view is equal to a given CGRect. I tried doing that like this:

CGRect rect = CGRectMake(20, 20, 20, 20); if (self.view.frame == rect) {     // do some stuff } 

However, I got an error saying Invalid operands to binary expression('CGRect' (aka 'struct CGRect') and 'CGRect'). Why can't I simply compare two CGRects?

like image 514
Tim Vermeulen Avatar asked Oct 13 '12 22:10

Tim Vermeulen


People also ask

What is a Cgrect?

A structure that contains the location and dimensions of a rectangle.

What is origin Swift?

A point that specifies the coordinates of the rectangle's origin.


1 Answers

Use this:

if (CGRectEqualToRect(self.view.frame, rect)) {      // do some stuff } 
like image 119
Amelia777 Avatar answered Sep 19 '22 17:09

Amelia777