无法在NSToolbar中的分段控件上对齐标签 [英] Can't align label on a Segmented Control in an NSToolbar
问题描述
从屏幕快照中可以看到,查看"按钮的文本在允许的工具栏项"下正确对齐,但是一旦将其添加到工具栏,它就会向右对齐.为什么?
As you can see from the screenshot, the View button text is aligned properly under Allowed Toolbar Items, but once I add it to the toolbar, it's aligned to the right. Why?
推荐答案
您必须为工具栏项设置合理的最小和最大大小.我认为您还必须确保在工具栏项的 view (在本例中为NSSegmentedControl)中正确设置了自动调整大小的蒙版(如果使用自动布局,则设置了约束).我没有方便的正确"设置,但是关键/最小/最大工具栏项目大小以及正确的自动调整大小行为是这里的关键.
You have to set sane minimum and maximum sizes for the toolbar item. I think you also have to make sure the autoresize masks (or constraints if you're using automatic layout) are set properly in the toolbar item's view (the NSSegmentedControl in this case). I don't have the "proper" settings handy but the min/max toolbar item size + correct autosizing behavior are the key here.
这篇关于无法在NSToolbar中的分段控件上对齐标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!