Hide UIToolbar UIBarButtonItems

后端 未结 6 1507
[愿得一人]
[愿得一人] 2020-12-03 08:12

I have a UIToolbar that I set up using IB with three buttons, left, middle and right. In some situations I would like to not display the middle button. Does anybody know of

6条回答
  •  长情又很酷
    2020-12-03 08:50

    Mohit's answer is one that I have used, but you dont need to specifically make it a NSArray that the toolbar sets. You can just set the array of items as a NSMutableArray. No real advantage that I am aware off but its a few lines less code. And that way you can take the array and move about UIButton objects as you would any other array with objects and then just reset the toolbar with that mutable array.

    [newToolBarArray removeObjectAtIndex:2];
    [newToolBarArray removeObjectAtIndex:1];
    [toolBar setItems:newToolBarArray];
    

提交回复
热议问题