I am creating Cancel button with my own Background image this way:
UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onCancel)];
[leftBarButton setBackgroundImage:[UIImage imageNamed:@"doneButtonActive.png"] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
[leftBarButton setBackgroundImage:[UIImage imageNamed:@"doneButtonInactive.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[self.navigationItem setLeftBarButtonItem:leftBarButton];
[leftBarButton release];
The problem I have, the button is too wide. It is almost twice bigger than it should be. I have tried to change width property with no effect. I am running iOS5 and it is the same on retina and non-retina display (I have two versions of images: for retina and non-retina displays).
Is it possible to change the width in other way? I know, I can create button with custom view, but it is not so “native” and I will have to make “Graphic guy” to change the images.
UPDATE
Problem solved. It is not possible to edit System style buttons. It is necessary to create UIButton with custom background and create UIBarButtonItem with custom view.
Problem solved. It is not possible to edit System style buttons. It is necessary to create UIButton with custom background and create UIBarButtonItem with custom view.