I have created 4 BarButtons with Image and when i added to navigation bar. It shows large gap in between the items and how can remove the gap between the image.
Asked
Active
Viewed 92 times
0
-
You need to post the code you used to add those buttons. A snapshot will be helpful as well. – ZeMoon Feb 12 '15 at 10:28
2 Answers
1
You can achieve this by maintaining image insets like this:-
UIBarButtonItem *demoButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"demo.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(saveStyle)];
demoButton.imageInsets = UIEdgeInsetsMake(0.0, 0.0, 0, -60);

Mohd Prophet
- 1,511
- 10
- 17
0
Fixed Item would help u to maintain ur gap. Add your images to button.
UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedItem.width = 10.;
UIButton *button1 = [[UIButton alloc]initWithFrame:CGRectMake(0., 0., 44., 44)];
UIBarButtonItem *barButton1 = [[UIBarButtonItem alloc]initWithCustomView: button1];
UIButton *button2 = [[UIButton alloc]initWithFrame:CGRectMake(46., 0., 44., 44)];
UIBarButtonItem *barButton2 = [[UIBarButtonItem alloc]initWithCustomView: button2];
UIButton *button3 = [[UIButton alloc]initWithFrame:CGRectMake(95., 0., 44., 44)];
UIBarButtonItem *barButton3 = [[UIBarButtonItem alloc]initWithCustomView: button3];
NSArray *itemArray = [[NSArray alloc] initWithObjects: barButton1, fixedItem, barButton2, fixedItem, barButton3, nil];
self.navigationItem.rightBarButtonItems = itemArray;

Dheeraj Singh
- 5,143
- 25
- 33