How can I add top layout guide in NIB file or how can I specify space from the top navigation bar and status bar so that it does not create problem between ios 6 and iOS 7?
            Asked
            
        
        
            Active
            
        
            Viewed 1.6k times
        
    29
            
            
        - 
                    2check this one http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7 – freelancer Nov 26 '13 at 05:35
- 
                    I use an alternative way. Check this http://stackoverflow.com/a/26397943/1021628 – Cao Huu Loc Oct 16 '14 at 06:56
3 Answers
27
            You can do this by by implementing new property called edgesForExtendedLayout in iOS7 SDK
-(void)viewDidLoad {
      if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
         self.edgesForExtendedLayout = UIRectEdgeNone;
}
or
If you are using navigation bar and xcode5 then..
In Interface Builder,select view controller, and then navigate to the attributes inspector. In "Extend Edges". check Under Top Bars
i have solved my problem from Here
- 
                    2Technically, you are accessing `setEdgesForExtendedLayout:` so you are kinda checking for response from the wrong method. But that's just nitpicking. – lxcid Sep 26 '14 at 05:24
- 
                    1This doesn't help, because I have a background that I want to be visible through a transparent navigation bar. `edgesForExtendedLayout` pushes everything down. – Jadar Sep 30 '15 at 03:06
3
            
            
        I think you need to write this condition for that
 float SystemVersion=[[[UIDevice currentDevice] systemVersion] floatValue];
  if(SystemVersion<7.0f)
   {
     //Currently your app is running in IOS6 or older version. So you need not 
             to do anything.
   }
  else
   {
     // Currently your app is running in IOS7.
   } 
 
    
    
        Parvendra Singh
        
- 965
- 7
- 19
-2
            
            
        I am doing it programmatically.
because you have to check both the frame sizes for ios 7 and others.
because for status bar you have to manage 20 pixel in IOS 7 and other.
so, just put View in XIB as you want in any IOS and for other you can manage by this...
CGSize result = [[UIScreen mainScreen] bounds].size;
        if(result.height == 480)
        {
   NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
            if ([[vComp objectAtIndex:0] intValue] >= 7) {
                NSLog(@"Ios7 resize the frame");
            }
            else
            {
            }
}
        if(result.height == 568)
        {
  NSArray *vComp = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
            if ([[vComp objectAtIndex:0] intValue] >= 7) {
                NSLog(@"Ios7 resize the frame");
            }
            else
            {
            }
Hope this helps....
 
    
    
        Sam
        
- 431
- 7
- 23
- 
                    The problem with this code is that it is highly dependent on the screen size. These kind of things tend to change often! – Artem Abramov May 08 '15 at 14:46
 
     
     
    