首页 > 代码库 > iOS 调整导航栏返回按钮的位置

iOS 调整导航栏返回按钮的位置

调整导航栏返回按钮的位置

//创建返回按钮UIButton * leftBtn = [UIButton buttonWithType:UIButtonTypeSystem];leftBtn.frame = CGRectMake(0, 0, 25,25);[leftBtn setBackgroundImage:[UIImage imageNamed:@"icon_back"] forState:UIControlStateNormal];[leftBtn addTarget:self action:@selector(leftBarBtnClicked:) forControlEvents:UIControlEventTouchUpInside];UIBarButtonItem * leftBarBtn = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];;//创建UIBarButtonSystemItemFixedSpaceUIBarButtonItem * spaceItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];//将宽度设为负值spaceItem.width = -15;//将两个BarButtonItem都返回给NavigationItemself.navigationItem.leftBarButtonItems = @[spaceItem,leftBarBtn];

iOS 调整导航栏返回按钮的位置