一个可直接替换 NSComboButton
的控件,并支持 macOS 13 之前的版本。
当您想采用 NSComboButton 但又必须保持与 10.13 的兼容性时使用。
DSFComboButton 尝试尽可能地匹配 NSComboButton 控件的 API。编程接口几乎相同,但是(不幸的是)自定义控件中的 Interface Builder 支持非常有限,所以我已尽力而为。
样式 | 描述 |
---|---|
.split |
一种样式,将按钮的标题和图像与人们用于激活按钮的菜单指示器分开。 |
.unified |
一种样式,将按钮的标题和图像与菜单指示器统一起来。 |
属性 | 类型 | 描述 |
---|---|---|
样式 |
DSFComboButton.Style |
要使用的控件样式 |
title |
String |
要在控件上显示的文本 |
image |
NSImage |
要在控件上显示的图像 |
imageScaling |
NSImageScaling |
图像如何缩放 |
target |
AnyObject |
按钮操作的目标 |
action |
Selector |
要在目标上调用的选择器 |
controlSize |
NSControl.ControlSize |
控件的大小 |
将 NSMenu 实例分配给 .menu
let button = DSFComboButton()
button.menu = NSMenu(...)
NSMenu
实例拖放到您的 XIB/Storyboard 中DSFComboButton
控件 Ctrl-Drag 到菜单,选择 menu
outletlet button = DSFComboButton()
button.target = /*some controller*/
button.action = #selector(buttonPressed(_:))
从 DSFComboButton
控件 ctrl-drag 到代码。
MIT License
Copyright (c) 2023 Darren Ford
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.