带有加号和减号按钮的 NSTableView [英] NSTableView with Plus and Minus buttons
问题描述
我怎么能做这样的事情?
How can I do something like that?
我在 Interface Builder 库中没有找到任何合适的对象.
I didn't find any appropriate object in the Interface Builder library.
有什么想法吗?
推荐答案
我发现的最好方法是使用 NSSegmentedControl.
The best way that i found is to use NSSegmentedControl.
在画布上拖动它后,你应该配置它的样式:
after you dragged it on the canvas, you should configure its style:
Style: Small Square
Mode: Select Momentary
看起来更好.现在使用图像"字段设置NSAddTemplate 和NSRemoveTemplate.确保标签字段为空.
looks better. Now use "image" field to set NSAddTemplate and NSRemoveTemplate. Make sure that label field is empty.
好的,我们有+"、-"和一个空段.要防止用户选择最新的一个,请从 Segment: 弹出并关闭 Enabled 复选框(位于 State: 旁边)中选择它强>标签).
Ok, we have "+", "-" and one empty segment. To prevent the latest one to be selected by the user, select it from Segment: pop up and turn off Enabled check box (located next to State: label).
最后,我们要做的是设置前两段的宽度,使它们成为正方形.
And lastly, what we have to do is set width of first two segments to make them square.
- 转到尺寸检查器
- 选择段 0
- 关闭固定"复选框(段应立即自动调整大小以适合图像)
- 选择段 1 并重复编号 3
- 现在当你调整控件大小时,只有最后一段会改变宽度
- 将它放在表格视图的底部并调整大小.
- Go to Size inspector
- Select Segment 0
- Turn off "Fixed" checkbox (segment should immediately autoresize to fit image)
- Select Segment 1 and repeat number 3
- Now as you resize control, only last segment will change width
- Put it at the bottom of your table view and resize as well.
享受;)
这篇关于带有加号和减号按钮的 NSTableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!