【发布时间】:2022-01-06 20:59:06
【问题描述】:
我一直在阅读有关如何在 NSTextField 上设置垂直对齐的各种选项。我希望文本显示在中心并在 Swift 中以编程方式进行。以下是我目前看过的内容:
- http://www.cocoabuilder.com/archive/cocoa/174994-repositioning-an-nstextfieldcell.html
- https://red-sweater.com/blog/148/what-a-difference-a-cell-makes
- Vertically Centre Text in NSSecureTextField with subclassing
- Get NSTextField contents to scale
- vertically align text in a CATextLayer?
我在 Swift 中尝试过的一件事是设置以下属性:
textField.usesSingleLineMode = true
任何关于将文本垂直居中的最佳方法的提示将不胜感激!
【问题讨论】: