2
UIButton *addButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [addButton setImage:[UIImage imageNamed:@"addButton.png"] forState:UIControlStateNormal]; 
    [addButton addTarget:self action:@selector(addSubProperty:) forControlEvents:UIControlEventTouchUpInside]; 
    [addButton setFrame:CGRectMake(0, 0,51,44)]; 

    UIBarButtonItem *firstBarButton = [[UIBarButtonItem alloc] initWithCustomView:addButton]; 

    UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [deleteButton setImage:[UIImage imageNamed:@"deleteButton.png"] forState:UIControlStateNormal]; 
    [deleteButton addTarget:self action:@selector(deleteProperty:) forControlEvents:UIControlEventTouchUpInside]; 
    [deleteButton setFrame:CGRectMake(0, 0,50,44)]; 

    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; 
    [negativeSpacer setWidth:-10]; 


    UIBarButtonItem *secondBarButton = [[UIBarButtonItem alloc]initWithCustomView:deleteButton]; 

    NSArray *navBtnArr = [[NSArray alloc] initWithObjects:negativeSpacer,firstBarButton,secondBarButton, nil]; 


    self.navigationItem.rightBarButtonItems = navBtnArr; 

enter image description here如何減少UINavigationBar IOS 7中UIBarButton項之間的填充?

在此之後我得到這個結果,因爲你們可以看到我所做的能夠管理移動我的第一barbutton離開BYT是negativeSpacer但我DONOT知道如何減少這兩個鍵之間的空間。

而通過這樣做我的背也消失了任何想法將真正讚賞。

+1

此鏈接對您有用 http://stackoverflow.com/questions/18897470/ios7-excessive-navigationbar-button-padding –

回答

4

使用Xcode 6.4,這對我來說非常適合1行代碼! https://stackoverflow.com/a/26469607/3634990

self.myBarButtonItem.imageInsets = UIEdgeInsetsMake(0, 25, 0, -25); 

注意,這個移動圖像的位置,但不是觸摸區域,所以它的前提是你要移動的圖像只是一點點很大的修復。

相關問題