在Snapchat应用程序中,当拖动表格视图以重新加载时,状态栏会更改alpha.
这是正常的状态栏
这是拖动表视图时发生的情况
状态栏alpha如何更改?框架是如何改变的?最初我认为这是一个快照,但时钟正常变化.
解决方法
这应该是淡入淡出动画的技巧:
/* Swift 3 */
let statusBarWindow = UIApplication.shared.value(forKey: "statusBarWindow") as? UIWindow
UIView.animate(withDuration: 2) {
statusBarWindow?.alpha = 0.2
}
/* Objective-C */
UIWindow *statusBarWindow = (UIWindow *)[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"];
[UIView animateWithDuration:2.f
animations:^{ [statusBarWindow setAlpha:0.2]; }
completion:nil];
您还可以设置statusBarWindow的框架并根据需要移动它.玩得开心 ;]