Positioning a bar button in toolbar at center in storyboard (in Portrait & Landscape)

StackOverflow https://stackoverflow.com/questions/19239472

  •  30-06-2022
  •  | 
  •  

문제

I have a toolbar in UIView form and a bar button to the right which has a huge caption "Add blah to blah" and no left bar button, The right bar button segues to multiple screens depending on UIform value on right button click.

I now need to add a button in center that does something else. I want this button to be in center irrespective of portrait or landscape. I added fixed space on either side to keep the center button in center. But the button goes to left in landscape mode, though it looks good in portrait.

Had it been programmatically adding, something like below might have worked

self.toolbarItems = [NSArray arrayWithObjects:flexibleSpaceBarButton, centerButton, flexibleSpaceBarButton, bigCaptionButton2, nil];

But most of the things have been done on storyboard and this new button needs to be in center. Is there a easy way to center a button in toolbar on a UIView in storyboard in both landscape and portrait mode ?

This is a toolbar button at the bottom of UIView form Thanks

도움이 되었습니까?

해결책

Drag flexible space objects from the object library and insert them on either side of the button you want centered.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top