iOS使用UINavigationBar和UIStatusBar缩放UIView

时间:2014-04-08 14:32:23

标签: ios uinavigationbar uistatusbar

我需要实现scrollview,其中包含使用UINavigationBar和UIStatusBar的几个缩放子视图。

如何让UIStatusBar在缩放视图上显示?因为现在我实现了这个(显示在左侧 - 没有状态栏的缩放视图)但我需要这个(如右图所示):

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
//get view controller and navigation controller from storyboard
UINavigationController *mainNavigControll = [sb instantiateViewControllerWithIdentifier:@"mainNavigControll"];
UIViewController *myViewObject = [sb instantiateViewControllerWithIdentifier:@"myViewController"];

//scaled view and all sub view
CGAffineTransform transform = CGAffineTransformMakeScale(scale, scale);
for( UIView* v in myViewObject.view.subviews )
    v.transform = transform;
[myViewObject.view addSubview:myViewObject.navigationController.view];
myViewObject.view.transform = transform;

//get navigation bar and set navigation item
UINavigationBar * navig_bar = mainNavigControll.navigationBar;
[navig_bar pushNavigationItem:myViewObject.navigationItem animated:NO];
//add navigation bar to view
[myViewObject.view addSubview:navig_bar];

//TODO: need added UIStatusBar ????
...

//add to scroll view
[_scrollView addSubview:myViewObject.view ];

此滚动视图必须看起来像iOS 7上的多任务处理,但仅限于一些内部视图。

1 个答案:

答案 0 :(得分:0)

在您拥有的自定义视图控制器中使用[[UIApplication sharedApplication] setStatusBarHidden:NO];