2013-10-08 2 views

ответ

8

Вы можете создать кнопку бара с пользовательским представлением, и в этом представлении вы можете создать свой собственный макет. Это может быть просто простой UIButton, и вы можете установить edgeInsets в UIButton.

см Customization of UINavigationBar and the back button

F.E.

UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
[btn setBackgroundImage:[UIImage imageNamed:@"chk_back.png"] forState:UIControlStateNormal]; 
[btn addTarget:self action:@selector(BackBtn) forControlEvents:UIControlEventTouchUpInside]; 
UIView *customView = [[[UIView alloc] initWithFrame:CGRectMake(0,0, 50, 38)] autorelease]; 
btn.frame = CGRectMake(10, 3, 30, 32); // where you can set your insets 
[customView addSubview:btn]; 
    UIBarButtonItem *barBtn = [[UIBarButtonItem alloc] initWithCustomView:customView]; 

Или вы можете добавить некоторые fixedSpace в баре или после Befor вашего пункта бар

UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] 
        initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace 
             target:nil 
             action:nil]; 
[fixedSpace setWidth:20]; 
1

Вы можете изменить imageInsets из rightBarButtonItem.

Например:

[viewController.navigationItem.rightBarButtonItem setImageInsets:UIEdgeInsetsMake(0, 0, 0, 50)]; 
Смежные вопросы