Iphone 如何在Spotify iOS应用程序中模拟可调整大小的状态栏
我一直在努力弄清楚Spotify如何在应用程序进入离线模式时创建UI。他们让状态栏看起来像是调整了大小,但实际上他们只是在下面放一个视图,并调整整个应用程序中所有控制器的大小。我已经尝试过子类化Iphone 如何在Spotify iOS应用程序中模拟可调整大小的状态栏,iphone,ios,uiview,uiviewcontroller,statusbar,Iphone,Ios,Uiview,Uiviewcontroller,Statusbar,我一直在努力弄清楚Spotify如何在应用程序进入离线模式时创建UI。他们让状态栏看起来像是调整了大小,但实际上他们只是在下面放一个视图,并调整整个应用程序中所有控制器的大小。我已经尝试过子类化UINavigationController,子类化UIWindow,调整窗口大小,但似乎没有任何东西适合每种情况 Spotify应用程序的有趣之处在于,当iOS自己的UIViewController子类以模式呈现时,他们的解决方案似乎仍然有效(如下图所示,显示了苹果的MFMailComposeViewC
UINavigationController
,子类化UIWindow
,调整窗口大小,但似乎没有任何东西适合每种情况
Spotify应用程序的有趣之处在于,当iOS自己的UIViewController
子类以模式呈现时,他们的解决方案似乎仍然有效(如下图所示,显示了苹果的MFMailComposeViewController
——可以看出它不是自定义控制器,因为UIBarButtonims)
如果有人知道这是怎么可能的,那就太棒了
这是一件非常危险的事。我过去也做过这样的事,我做过噩梦。下面是在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];
}
这就是它的样子:
我很好奇,当你展示一个模态viewController时,你的“股票代码”是否仍然位于所有内容之上?我已经尝试过你正在做的事情(调整NavigationController视图的大小)。我的ticker是在UINavigationController级别添加的,因此即使在切换UIViewController时,它也会持续存在。你可以用同样的方法调整你的模式uiViewController,这样你就能得到想要的效果。你能详细说明一下“噩梦”吗?