1、导航栏返回按钮无文字设置:
用的下面方法设置的导致按钮向下偏移的
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0,-60) forBarMetrics:UIBarMetricsDefault];
解决办法:
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-200, 0) forBarMetrics:UIBarMetricsDefault];
2、使用tableView时,状态栏空出20像素
解决办法:
self.extendedLayoutIncludesOpaqueBars = YES;
if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
3、自定义导航栏返回按钮,UIBarButtonSystemItemFixedSpace失效
解决办法:
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStyleDone target:self action:@selector(backBtnClick)];
if (@available(ios 11.0,*)) {
leftItem.imageInsets = UIEdgeInsetsMake(0, -10, 0, 0);
self.navigationItem.leftBarButtonItem = leftItem;
} else {
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
negativeSpacer.width = -10;
self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:negativeSpacer, leftItem, nil];
}
网友评论