Search code examples
iosobjective-cios7ios6statusbar

how to fix status bar overlap issue in ios 7


I am developing an application that's working fine in IOS6. But in iOS7, the status bar overlaps with the view.

As an example : IOS7

I need the status bar first, and then my icons and Remove last .So Please give me any idea about how to remove the overlap.

but I need this

enter image description here Please give me any idea about my problem


Solution

  •  -(void)viewWillLayoutSubviews{
    
     if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) 
      {
        self.view.clipsToBounds = YES;
        CGRect screenRect = [[UIScreen mainScreen] bounds];
        CGFloat screenHeight = 0.0;
        if(UIDeviceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]))
            screenHeight = screenRect.size.height;
        else
            screenHeight = screenRect.size.width;
        CGRect screenFrame = CGRectMake(0, 20, self.view.frame.size.width,screenHeight-20);
        CGRect viewFr = [self.view convertRect:self.view.frame toView:nil];
        if (!CGRectEqualToRect(screenFrame, viewFr))
        {
            self.view.frame = screenFrame;
            self.view.bounds = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
        }
      }
    }