The statusBarFrame returns the frame in screen coordinates. I believe the correct way to get what this corresponds to in view coordinates is to do the following:
- (CGRect)statusBarFrameViewRect:(UIView*)view
{
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
CGRect statusBarWindowRect = [view.window convertRect:statusBarFrame fromWindow: nil];
CGRect statusBarViewRect = [view convertRect:statusBarWindowRect fromView: nil];
return statusBarViewRect;
}
Now in most cases the window uses the same coordinates as the screen, so [UIWindow convertRect:fromWindow:]
doesn't change anything, but in the case that they might be different this method should do the right thing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…