Solution 1:

Use this:

if (CGRectEqualToRect(self.view.frame, rect)) {
     // do some stuff
}

Solution 2:

See the documentation for CGRectEqualToRect().

bool CGRectEqualToRect ( CGRect rect1, CGRect rect2 );

Solution 3:

In the Swift 3 it would be:

frame1.equalTo(frame2)

Solution 4:

In Swift simply using the == or != operators works for me:

    let rect = CGRect(x: 0, y: 0, width: 20, height: 20)

    if rect != CGRect(x: 0, y: 0, width: 20, height: 21) {
        print("not equal")
    }

    if rect == CGRect(x: 0, y: 0, width: 20, height: 20) {
        print("equal")
    }

debug console prints:

not equal
equal