2

我正在尝试更改NSTextFieldmacOS 应用程序的高度。

如何更改我的高度并使文本像iOS 上NSTextField的正常一样垂直居中。UITextField我添加了一个高度约束来尝试让它更大,并且什么都不会改变。

class LoginVC: NSViewController {

@IBOutlet weak var emailField: TF!
@IBOutlet weak var passwordField: STF!

override func viewDidLoad() {
    super.viewDidLoad()

    emailField.usesSingleLineMode = true
    emailField.placeholderAttributedString = NSAttributedString(string: "Email", attributes: [NSForegroundColorAttributeName: NSColor.lightGray, NSFontAttributeName: NSFont(name: "Menlo", size: 20)!])
    emailField.alignment = .center

    passwordField.usesSingleLineMode = true
    passwordField.placeholderAttributedString = NSAttributedString(string: "Password", attributes: [NSForegroundColorAttributeName: NSColor.lightGray, NSFontAttributeName: NSFont(name: "Menlo", size: 20)!])
    passwordField.alignment = .center
}

override func viewWillAppear() {
    super.viewWillAppear()

    view.layer?.backgroundColor = EYE_GREY.cgColor
}

}

在此处输入图像描述

4

0 回答 0