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放在数组的第一个
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。