将UIToolBar上的按钮居中

时间:2011-07-26 12:09:12

标签: ios ipad interface-builder uitoolbar

我需要将B项相对于工具栏居中。我在界面构建器中创建了以下内容:

Item B in the center

在动态插入其他项目之前一切正常:

Item B not in the center

如何保持B项的集中位置?一个想法是使用固定空格键按钮项,但我不能,因为工具栏的长度也会改变(对于不同的方向)。

1 个答案:

答案 0 :(得分:1)

每次标签栏改变大小时都可以使用它:

//lets be tabBar the big view and buttonB the.. well, button B
[buttonB setCenter:CGPointMake(tabBar.frame.size.height/2, tabBar.frame.size.width/2);