UINavigationBarItem 調(diào)整距離左右邊界的大小
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(5, 22, pixwn(44), pixwn(15));
[button setTitle:@"取消" forState:UIControlStateNormal];
button.titleLabel.font = kXHFont(19);
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:_button];
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action:nil];
negativeSpacer.width = -pixwn(10); //減小距離,width屬性為負值,加大距離,width屬性為正值
self.navigationItem.leftBarButtonItems = @[negativeSpacer,backItem];//無論左邊或者右邊的item,調(diào)整間距的item放在數(shù)組的第一個
最后編輯于 :
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者