iOS11 怎么调整 rightBarButtonItems 的位置?

iOS 10 及以下版本可以通过下面的形式改 位置

    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn1 setTitle:@"yyyyy"  forState:UIControlStateNormal];
    [btn1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [btn1 sizeToFit];
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithCustomView:btn1];
    
    
    UIBarButtonItem *fixed = [[UIBarButtonItem alloc]
                              initWithBarButtonSystemItem: UIBarButtonSystemItemFixedSpace
                              target:nil
                              action:nil];
    fixed.width = -22;
    
    self.navigationItem.rightBarButtonItems  = @[fixed, item1];

iOS11 开始这种方法不行了,
请问iOS11 该如何调整?

比如现在想调整 y 按钮距离右边的距离是5,该如何做?

clipboard.png

阅读 6.3k
2 个回答

用 initWithCustomView: custom是定制,
你用的 initWithBarButtonSystemItem System是系统的。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题