NOUSguide / NGTabBarController

A custom TabBarController implementation for iPhone and iPad
Other
263 stars 0 forks source link

Tab at Bottom #11

Open cannyboy opened 12 years ago

cannyboy commented 12 years ago

Apps with vertical tab bars, like Instapaper and Spotify, often have tabs at the bottom, separated from the main tabs.

I did this with NGTabBarController, by adding a BOOL property to NGTabBarItem:

@property (readwrite, assign) BOOL atBottom;

Then I changed some code in NGTabBar.m

// re-position each item starting from current top/left
for (NGTabBarItem *item in self.items) {
    CGRect frame = item.frame;

    frame.origin.y = currentFrameTop;
    frame.origin.x = currentFrameLeft;
    item.frame = frame;

    // move to next item position
    if (NGTabBarIsVertical(self.position)) {
        currentFrameTop += frame.size.height;
        currentFrameTop += appliedItemPadding;
    } else {
        currentFrameLeft += frame.size.width;  
        currentFrameLeft += appliedItemPadding;
    }

    if (item.atBottom)
    {
        item.frame = CGRectMake(frame.origin.x, (self.frame.size.height - frame.size.height)-appliedItemPadding, frame.size.width, frame.size.height);
    }

}

Only works for vertical tab bars, so would probably need a more robust system.. perhaps like UIToolbars with fixed and flexible spacing items.