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];; //建立UIBarButtonSystemItemFixedSpace UIBarButtonItem * spaceItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; //将宽度设为负值 spaceItem.width = -15; //将两个BarButtonItem都返回给NavigationItem self.navigationItem.leftBarButtonItems = @[spaceItem,leftBarBtn];

转载于:https://www.cnblogs.com/tongyuling/p/5948276.htmlhtml