Search code examples
iphoneiosuitoolbartap

UIBarButtonItem - Invalid tap glow size


I have a strange problem with glow that appears when pressing on a UIBarButtonItem in the UIToolbar control. When I set ImageInsets property to 4,0,0,0 the glow gets smaller every time I tap on it. Here is an illustration:

Tap glow problem

The problem doesn't appear if I don't set imageInsets. The problem appears for all buttons in the UIToolbar. I don't have tap handlers. Making bigger inset (e.g. 8,0,0,0) produces the same result faster.

I appreciate any suggestions on how to solve the problem.

EDIT: Changed the code to Objective-C since the problem reproduces without MonoTouch as well.

It's default single view project. I added a toolbar and a UIBarButtonItem into it using storyboard designer. Created an outlet for the button.

#import "ViewController.h"

@implementation ViewController
@synthesize testBtn;

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];

    UIEdgeInsets insets = UIEdgeInsetsMake(8, 0, 0, 0);
    [testBtn setImageInsets:insets];
}

- (void)viewDidUnload
{
    [self setTestBtn:nil];
    [super viewDidUnload];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end

Solution

  • Finally, I asked designer to adjust image size and thus get rid of the imageSize property use.