UINavigationBarItem 调整距离左右边界的大小
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,调整间距的item放在数组的第一个
网友评论