导航栏 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)];

你可能感兴趣的:(导航栏 item 距离调整)