gpt4 book ai didi

iphone - 如何在 Spotify iOS 应用程序中模仿可调整大小的 StatusBar

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:46:32 26 4
gpt4 key购买 nike

我一直在努力弄清楚 Spotify 如何在应用进入离线模式时创建 UI。他们让 StatusBar 看起来像是调整了大小,但实际上他们只是在下方放置了一个 View ,并调整了整个应用程序中所有 Controller 的大小。我试过子类化 UINavigationController、子类化 UIWindow、调整窗口大小,但似乎对所有情况都不起作用。

关于 Spotify 应用程序的有趣之处在于,当 iOS 自己的 UIViewController 子类以模态方式呈现时,他们的解决方案似乎仍然有效(如下图所示,显示了苹果的 MFMailComposeViewController - 由于 UIBarButtonItems,您可以看出它不是自定义 Controller )。

如果有人知道这是如何实现的,那就太棒了。

Spotify iOS app

最佳答案

这是一件非常危险的事情。我过去做过,我做过噩梦。下面是适用于 iOS4 并支持方向更改的代码。

- (void) _adjustViewControllerforTicker {
TickerView* vv = [ApplicationContext getTickerView];
if ([PreferenceDataModel isFxTickerOn]&& self.navigationController.view.frame.origin.y==0) {

CGRect tableRect = self.tableView.frame;
self.tableView.frame = CGRectMake(tableRect.origin.x,tableRect.origin.y, tableRect.size.width, tableRect.size.height -20);
UINavigationController *nav = self.navigationController;
CGRect gframe = CGRectOffset(self.navigationController.view.frame, 0, 20);
self.navigationController.view.frame = gframe;
if (!vv) {
vv = [[TickerView alloc] initWithFrame:CGRectMake(0, 0, 480, 20)];

[nav.view addSubview:vv];
[vv release];
self.tableView.contentInset=UIEdgeInsetsMake(0,0,20.0,0.0);
[ApplicationContext setTickerView:vv];
}

if (![PreferenceDataModel isTickerOn]) {
self.tableView.contentInset= UIEdgeInsetsZero;
if (vv){
[vv removeFromSuperview];
vv=nil;
[ApplicationContext setTickerView:nil];
}
}

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self _adjustViewControllerforTicker];
}

- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self _adjustViewControllerforTicker];
TickerView* vv = [ApplicationContext getTickerView];
if ([vv count]) {
[vv startAnimation];
}
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self _adjustViewControllerforTicker];
}

这是它的样子:

enter image description here

关于iphone - 如何在 Spotify iOS 应用程序中模仿可调整大小的 StatusBar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7721584/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com