0

I have created a custom navigation bar in ipad with height of 80. In this case there occurs an issue with bask buttons frame.

The height of navigation bar increased but the back button's height is same as before with height os navigation bar as 44. here the navigation bar heigh increases to 80 so accordingly i want to change the frame of back button also.

I know we can add a custom back button but i dnt want to create 15 image for 15 view with name of each screen. i want to change frame of default back buttons.

here is my code to customise navigation bar

#import "UINavigationBar+navbar.h"

@implementation UINavigationBar (navbar)

- (CGSize)sizeThatFits:(CGSize)size {
     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
         CGSize newSize = CGSizeMake(self.frame.size.width,44);
         return newSize;
     }
     else{
         CGSize newSize = CGSizeMake(self.frame.size.width,80);
         return newSize;
     }
}
287986
  • 93
  • 1
  • 12

2 Answers2

0

No!!! you can't change the frame of bar button items. Though UIBarButtonItem is similar to UIButton but inherits from UIBarItem and UIBarItem from NSObject not from UIControls. If you want specify size than you can customize UIBarButtonItem or simply use UIButton instead of UIBarButtonItem.

Suryakant Sharma
  • 3,852
  • 1
  • 25
  • 47
0

Create a BarButtonItem with a UIImageView ,you can change the frame of the custom UIImageView.

   UIImageView* imageView = [[[UIImageView alloc] initWithFrame:navigationController.navigationBar.frame] autorelease];
imageView.contentMode = UIViewContentModeLeft;
imageView.image = [UIImage imageNamed:@"NavBar-iPhone.png"];
[navigationController.navigationBar insertSubview:imageView atIndex:0];
Suhaiyl
  • 1,071
  • 9
  • 17