I added an UIWindow with a subView of an UIView to current key window.
CGFloat width = 35;
self.window = [[UIWindow alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height - width, width, width)];
self.window.backgroundColor = [UIColor yellowColor];
self.window.windowLevel = UIWindowLevelStatusBar;
self.window.hidden = NO;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, width)];
view.backgroundColor = [UIColor redColor];
[self.window addSubview:view];
And when I called
[[UIApplication sharedApplication] setStatusBarHidden:sender.selected withAnimation:UIStatusBarAnimationSlide];
In iOS7, after the window has been added, the window's height changed automatically to the screen's height
So what may cause this problem?