2

Is it possible to add tow buttons under the navigation bar in iOS like shown in the image below:

If yes, please tell me how it can be done.

enter image description here

Singularity
  • 143
  • 12
Bacem
  • 207
  • 1
  • 14
  • That's an Android screenshot. iOS and Android have different guidelines concerning this. On iOS, you'll typically want to put a `UISegmentedControl` as the title view of your navigation item. – Cyrille May 29 '15 at 09:13
  • I guess, PetahChristian has pointed you quite in right direction. However, my suggestion is to create a custom view in a way that it appears like a navigation bar. – Natasha May 29 '15 at 09:19
  • If an answer helped, please take a minute to accept it. Otherwise, comment on an answer (or update your question) if you need more help! :) –  Jun 01 '15 at 10:58

2 Answers2

3

Look at the ExtendedNavBar example in Apple's Customizing UINavigationBar sample code.

1

Practically it's possible to do the same ;but i won't suggest you to do this,As this might break the app in upcoming release of iOS..

If you want to do this then check the post here on Stackoverflow

iPhone - How set uinavigationbar height?

it will helps you making the navigation bar taller. Simply create a custom UINavigationBar subclass, which overrides sizeThatFits: and returns a large size.

const CGFloat HeightToIncrease = 50.0f;

@implementation MyNavigationBar

- (CGSize)sizeThatFits:(CGSize)size {

    CGSize amendedSize = [super sizeThatFits:size];
    amendedSize.height += HeightToIncrease;

    return amendedSize;
}

@end

You view will looks like the ![following][1]

Now just override layoutSubviews in the navigation bar subclass and move the buttons and title up to make room for buttons

like following

- (void)layoutSubviews {
    [super layoutSubviews];     

    NSArray *classNamesToReposition = @[@"UINavigationItemView", @"UINavigationButton"];

    for (UIView *view in [self subviews]) {

        if ([classNamesToReposition containsObject:NSStringFromClass([view class])]) {

            CGRect frame = [view frame];
            frame.origin.y -= HeightToIncrease;

            [view setFrame:frame];
        }
    }
}

this will make the room for the buttons you want to place in the navigation .

Community
  • 1
  • 1
Shekhu
  • 1,998
  • 5
  • 23
  • 49