pls
pls

Reputation: 1532

UITabBarItems disappear when setting new frame of UITabBar

In my application when the contact tab is clicked (Middle button), I want to move the UITabBar up from the bottom of the screen and display a view below it.

However when I move the UITabBar up with the following code, the UITabBarItems disappear:

- (void)moveTabBarUpwards
{
    [self.tabBar setFrame:CGRectMake(0, 300, self.view.frame.size.width, self.view.frame.size.height)];
    //[self.tabBar.items[0] setFrame:CGRectMake(0, 300, self.view.frame.size.width, self.view.frame.size.height)];
}

Here is the result:

enter image description here enter image description here

Even though the tabs disappear, the toolbar still functions correctly in the new position. Not sure why this is happening.

Edit

If I move the tab bar right to the top then the UITabBarItems remain in the same place. If I move the y to say 10 I get the following (as you can see, the UITabBarItems are still visible but have move down slightly):

enter image description here

Upvotes: 0

Views: 246

Answers (1)

Sergey Grishchev
Sergey Grishchev

Reputation: 12051

I doubt that altering iOS' standard UI elements frames directly is a good point at all. Same goes here for UINavigationBar for example.

I'd advise you to create your own model of a UIView with UIButtons and a parent view controller with child VCs as tabs. This way, you'll be 100% safe in future iOS releases, because no one beside Apple really knows which way any given component of iOS is going to go.

Upvotes: 2

Related Questions