2013-02-27 5 views
0

У меня есть приложение, которое я хочу, чтобы кнопка на панели навигации была в желаемой позиции, но она не выполняется. Я нашел методы для rightBarButton и leftBarButton, но я хочу, чтобы это было в центре панели навигацииДобавление в навигационную панель в нужную позицию

UIButton *settingsView = [[UIButton alloc] initWithFrame:CGRectMake(0,0,40,40)]; 
[settingsView addTarget:self action:@selector(SettingsClicked) forControlEvents:UIControlEventTouchUpInside]; 
[settingsView setBackgroundImage:[UIImage imageNamed:@"login btn.png"] forState:UIControlStateNormal]; 
UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithCustomView:settingsView]; 
[self.navigationItem setRightBarButtonItem:settingsButton]; 

ответ

0
NSMutableArray *arrayOfItems = [[NSMutableArray alloc] init]; 

UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] 

[arrayOfItems addObject:flexibleSpace]; 
[arrayOfItems addObject:theItemYouWantCentered]; 
[arrayOfItems addObject:flexibleSpace]; 

self.navigationItem.leftBarButtonItems = arrayOfItems; 
Смежные вопросы