简体   繁体   中英

Is it possible to change frame of view controller in UITabBarController so that UITabBarController view will be visible?

I have my own subclass of UITabBarViewController. Is it possible to change frame for all embedded viewcontrollers' views so that own UITabBarViewController view will be visible partially?

On the attached image I set purple color for own tabBarController view. I want to change frame of each selected view controller so that this purple view (UITabBarController view) will be visible. 在此输入图像描述

I stumbled upon this answer looking for a solution myself, and found an okayish way to handle this: wrap your viewController inside another viewController as a childViewController.

Essentially, you would present a viewController with clear background, which has your content controller as childController with a frame you want it to have:

UIViewController *wrapperController = [UIViewController new];
wrapperController.backgroundColor = [UIColor clearColor];

[wrapperController addChildViewController:vc];
[wrapperController.view addSubview:vc.view];
vc.view.frame = CGRectMake(...);

Just make sure to pass the tabbarItem to the wrapper, and use that one instead of the child.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM