Insert space / view / image between UITabbar elements

Porting an application to the ipad and in the landscape tabs seems a bit rare, so the idea of โ€‹โ€‹separating tabs (6 of them) and inserting an image between them.

I am currently using TabBarKit , and it does everything and everything that UITabbar does, but thatโ€™s what Iโ€™m kind of stuck with. Could not find a way to insert a blank space, either an image or a UIView (the background is already an image)?

What I have done so far is to programmatically add a few extra tabs and set the image to zero and remove user interaction. (I found this solution in another stackoverflow, but this is not an ideal solution).

I know that UIToolbar has a flexible space element, but when I tried to use it as a tab bar item , it caused some problems.

So, if anyone has any ideas on how to insert a view, empty space, etc. in the tab bar, we will be very grateful.

UPDATE

Begin generosity because I'm interested in knowing if this can be done or not. There is a lot of space in the landscape view of the iPad, and I was asked to put the image in the middle, breaking the buttons.

If the application is rejected, then more than me will deceive. Any examples, examples, suggestions, tips were highly appreciated.

Image example: enter image description here

+6
source share
2 answers

I would agree with the answer above that this is probably not a good idea, technically, although it is possible.

The trick on the user tab is to hide the default panel and place your own custom view in this space. Then you can fill this view with buttons, images, whatever you want. This is how I dealt with this.

I installed my UITabbarController, like this in AppDelegate:

 UITabBarController tabBarController = [[UITabBarController alloc] init]; tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3, nil]; //add the custom tabbarcontroller CustomTabBar customTabBar = [[CustomTabBar alloc] initWithFrame:CGRectMake(0, self.window.frame.size.height - 60, self.window.frame.size.width, 62)]; [self.tabBarController.view addSubview:_customTabBar]; tabBarController.tabBar.hidden = YES; self.window.rootViewController = self.tabBarController; 

CustomTabBar is a subclass of UIView where I put my own custom buttons. When a button is clicked in this class, I make a call that looks like this:

 -(void)firstBtnClicked:(id)sender { ((UIButton*)sender).enabled = NO; AppDelegate *delegate = (AppDelegate*)[UIApplication sharedApplication].delegate; delegate.tabBarController.selectedIndex = 0; } 
+5
source

I would discourage you from messing with Apple's well-thought-out tab bar. Do not do this - you are badly cracking your own control, and this will have consequences in the future. In addition, you will have to deal with different intervals and logic in landscape and portrait mode. Do not complicate things unnecessarily, use them as designed or reinterpreted whether the tab bar is a suitable control.

Quote from the Apple Guide :

On the iPad, display the same tabs in each orientation to increase the visual stability of your application. In the portrait, seven tabs are recommended to fit the width of the screen. In landscape orientation, you should center the same tabs along the width of the screen. This guide also applies to using the tab bar in split panel or popover mode. For example, if you use the tab bar in a popover in a portrait, it works well to display the same tabs in the left pane of a split view in the landscape.

+4
source

Source: https://habr.com/ru/post/916096/


All Articles