简体   繁体   中英

iOS 7 UIView - Subview overlapping on status bar

I created a UIView container for a registration form, inside there aa subview for login form. So navigating through "Already registered button" action

- (IBAction)registeredButton:(id)sender {
    [UIView animateWithDuration:0.3 animations:^{
        _loginOverlayView.frame = self.view.frame;
    }];
}

My problem is basically; why subview overlapping on status bar. How can i fix it!

_loginOverlayView

在此处输入图片说明

ps: Using Xcode 5, iOS7

Open Storyboard, in settings of your view controller check Attribution Inspector. In Extend Edges first line 'Under top bars' should be ticked

在此处输入图片说明

UPD:

What about 'Use Auto Layout' in File Inspector? Ticked?

在此处输入图片说明

UPD2:

Oh, I think you should shift down your view for 64px (20px status bar, 44px navigation controller). Coz, somehow your insets and layouts doesn't work

#define IS_IOS_7 ([[UIDevice currentDevice].systemVersion floatValue] < 7.0 ? NO : YES)

if (IS_IOS_7)
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
}

In iOS 7 view's (0,0) starts from device's (0,0) ie inside status bar.

You can fix it either by autolayout in storyboard or code ... or you can simply add 20 pixels to the view's frame if it's iOS 7....

ie

#define ISOS_7    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM