iOS设置导航栏左按钮的位置

UIButton*leftbutton = [selfset_leftButton];

[leftbuttonaddTarget:selfaction:@selector(left_click:)forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem*item = [[UIBarButtonItemalloc]initWithCustomView:leftbutton];

UIBarButtonItem* spaceItem = [[UIBarButtonItemalloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpacetarget:nilaction:nil];

//将宽度设为负值

spaceItem.width= -20;

//将两个BarButtonItem都返回给NavigationItem

self.navigationItem.leftBarButtonItems=@[spaceItem ,item];

你可能感兴趣的:(iOS设置导航栏左按钮的位置)