2015-02-12 2 views
0

Я создал 4 BarButtons с изображением и когда я добавил в панель навигации. Он показывает большой разрыв между предметами и как можно удалить промежуток между изображением.Добавление BarButton в rightBarButtonItems

+0

Вам нужно разместить код, используемый для добавления этих кнопок. Также будет полезен снимок. – ZeMoon

ответ

0

Неподвижный элемент поможет вам сохранить ур. Добавьте свои изображения к кнопке.

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; 
1

Вы можете добиться этого путем поддержания врезки изображения, как это: -

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); 
Смежные вопросы