DSFLabelledTextField

一个使用 Swift 编写的简单 macOS 带标签文本框。

安装

Swift Package Manager

https://github.com/dagronf/DSFLabelledTextField 添加到您的项目中。

CocoaPods

将以下内容添加到您的 Podfiles 文件中

pod 'DSFLabelledTextField', :git => 'https://github.com/dagronf/DSFLabelledTextField'

直接添加

Sources/DSFLabelledTextField 子文件夹中的 Swift 文件添加到您的项目中

使用方法

  1. 使用 Interface Builder 添加一个新的 NSTextField,然后将类类型更改为 DSFLabelledTextField,或者
  2. 以编程方式创建一个

属性

分组字段

有时您可能需要同步多个字段的标签宽度。 为此,您可以将这些字段添加到 DSFLabelledTextFieldGroup 实例,字段标签将调整大小以适应组中所有标签的最大宽度。

示例

@IBOutlet weak var redField: DSFLabelledTextField!
@IBOutlet weak var greenField: DSFLabelledTextField!
@IBOutlet weak var blueField: DSFLabelledTextField!
let colorGroup = DSFLabelledTextFieldGroup()

override func viewDidLoad() {
   super.viewDidLoad()

   /// Sync the widths of the red, green and blue labels
   self.colorGroup.add(fields: redField, greenField, blueField)
}

更多截图

历史

许可

MIT License

Copyright (c) 2020 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.