Compose UIBarButtonItem changes position slightly when coming into view

后端 未结 7 2046
星月不相逢
星月不相逢 2021-02-13 15:21

When presenting a new view with a UIBarButtonSystemItemCompose button in the navigation bar, the position is slightly off and adjusts after the view has come into view.

7条回答
  •  野性不改
    2021-02-13 15:58

    I used Sergey's answer, but kept an empty space right of my button. I fixed this with a negative spacer, which now works beautifully:

    UIBarButtonItem* composeBarButtonItem =
    [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
                                                  target:nil
                                                  action:nil];
    
    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
                                           initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
                                           target:nil action:nil];
    negativeSpacer.width = -6;
    
    UIBarButtonItem *dumbBarButtonItem = [UIBarButtonItem new];
    
    self.navigationItem.rightBarButtonItems = @[dumbBarButtonItem, negativeSpacer, self.composeBarButtonItem];
    

提交回复
热议问题