0
UIBarButtonItem *adminBarButtonItem = [[UIBarButtonItem alloc] 
                                          initWithImage:[UIImage imageNamed:@"779-users"] 
                                          style:UIBarButtonItemStylePlain 
                                          target:self 
                                          action:@selector(adminButtonTouched)];

I tried to assign a new frame to adminBarButtonItem.customView.frame, it didn't work.

Expect for [[UIBarButtonItem alloc] initWithCustomView:aView], is there anyway to change the size of UIBarButtonItem?

David Liu
  • 16,374
  • 12
  • 37
  • 38

1 Answers1

0

I encountered a similar situation where I needed to resize a custom image to fit alongside another system bar button item. The key is to resize the image itself before I use it in UIBarButtonItem's initWithImage method.

For how to resize that UIImage, follow this link The simplest way to resize an UIImage?

Another pitfall is the tintColor of the custom button item. I used

myButtonItem.tintColor = [UIColor colorWithPatternImage:myImage];

to get around the blue tint that covers up my image (iOS8), but I suspect there exists a more kosher way. If anybody knows, please enlighten me.

Community
  • 1
  • 1
Hackless
  • 385
  • 5
  • 14