导航栏 item 距离调整

UIButton* rightfirstbtn= [UIButton buttonWithType:UIButtonTypeCustom];
[rightfirstbtn setBackgroundImage:[UIImage imageNamed:@"bubble"] forState:UIControlStateNormal];
[rightfirstbtn setTarget:self action:@selector(talksendmessage) forControlEvents:UIControlEventTouchUpInside];
rightfirstbtn.frame= CGRectMake(0, 0, 23, 23);
UIBarButtonItem *rightmessagebtn = [[UIBarButtonItem alloc] initWithCustomView: rightfirstbtn];
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action:nil];

negativeSpacer.width = -10;
UIButton* rightsecondebtn= [UIButton buttonWithType:UIButtonTypeCustom];
[rightsecondebtn setBackgroundImage:[UIImage imageNamed:@"shop"] forState:UIControlStateNormal];
[rightsecondebtn setTarget:self action:@selector(goingtoshop) forControlEvents:UIControlEventTouchUpInside];
 rightsecondebtn.frame= CGRectMake(0, 0, 23, 23);
 rightsecondebtn.width =25;//距离右边的距离 默认是5PX

UIBarButtonItem *rightshopbtn= [[UIBarButtonItem alloc] initWithCustomView:rightsecondebtn];
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:negativeSpacer,rightmessagebtn,rightshopbtn,nil];

 self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"深圳" style:UIBarButtonItemStylePlain target:self action:@selector(locatingAction)];
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容