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 CGRect
s?
A structure that contains the location and dimensions of a rectangle.
A point that specifies the coordinates of the rectangle's origin.
Use this:
if (CGRectEqualToRect(self.view.frame, rect)) { // do some stuff }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With