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

回答:

这里给出的解决方案可以用
https://stackoverflow.com/que...

回答:

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

以上是 iOS11 怎么调整 rightBarButtonItems 的位置? 的全部内容, 来源链接: utcz.com/p/184018.html

回到顶部