鍍金池/ 問答/C  iOS  HTML/ iOS11 怎么調(diào)整 rightBarButtonItems 的位置?

iOS11 怎么調(diào)整 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 開始這種方法不行了,
請(qǐng)問iOS11 該如何調(diào)整?

比如現(xiàn)在想調(diào)整 y 按鈕距離右邊的距離是5,該如何做?

clipboard.png

回答
編輯回答
吢丕

用 initWithCustomView: custom是定制,
你用的 initWithBarButtonSystemItem System是系統(tǒng)的。

2018年2月18日 20:24
編輯回答
凝雅

這里給出的解決方案可以用
https://stackoverflow.com/que...

2017年9月30日 01:48