iOS 7淡入淡出状态栏文本?
我知道可以删除状态栏,但如果将状态栏设置为隐藏状态,则框架会向上移动状态栏的高度。 因此,以下代码:
[UIApplication sharedApplication].statusBarHidden = YES;
仅仅隐藏状态栏的文本是不够的。 我最终尝试在这里完成的工作与Gmail应用程序类似,在显示侧边菜单时,状态栏文本被隐藏,然后一旦选择,框架将恢复正常状态栏文本显示。
此问题显示如何为状态栏的隐藏设置动画,但结果是整个窗口向上移动状态栏的高度。 我试图避免这种情况发生。
Objective-C版本:
[AppDelegate instance].window.windowLevel = UIWindowLevelStatusBar;
Swift版本:
AppDelegate().window!.windowLevel = UIWindowLevelStatusBar
这应该做到这一点。 然而,这有点像黑客攻击:
NSString *key = [[NSString alloc] initWithData:[NSData dataWithBytes:(unsigned char []){0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x61, 0x72} length:9] encoding:NSASCIIStringEncoding]; id object = [UIApplication sharedApplication]; UIView *statusBar; if ([object respondsToSelector:NSSelectorFromString(key)]) { statusBar = [object valueForKey:key]; } [UIView animateWithDuration:0.3 animations:^{ statusBar.alpha = 0.0f; } ];
以某种方式在我的代码结果中应用以下代码,同时展开可选的nil
AppDelegate().window!.windowLevel = UIWindowLevelStatusBar
我使用以下方法使状态栏文本隐藏:
UIApplication.shared.delegate?.window!!.windowLevel = UIWindowLevelStatusBar
并将状态栏重置为默认值并显示文本:
UIApplication.shared.delegate?.window!!.windowLevel = UIWindowLevelNormal
- 为什么SKShapeNode没有定位点?
- Samsung Health:帐户同步和备份
- UICollectionView indexPathsForVisibleItems不更新新的可见单元格
- iOS:使用全屏图像构建幻灯片
- Swift – 如何在Core Data中获取最后一个插入ID,将其存储在NSUserDefault和谓词中
- SpriteKit:使用SKTextureAtlas会导致不正确的Physics Body
- 约百分比完成在GKAchievement
- 解释想要:UIViewController和UIView之间传递数据的概念
- 在UIApplicationStateBackground状态中更改UIScrollView的zoomScale和contentOffset