macOSアプリケーションの場合、NSTextField
の高さを変更しようとしています。NSTextFieldの高さを変更するには?
NSTextField
の高さをどのように変更し、iOS上で通常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
}
}
フォントサイズが20.0の属性付き文字列をテキストフィールドに設定したいのはなぜですか?私はあなたの仕事が非常に未熟であると感じます。 –
ストーリーボードにフォントを設定してみませんか?これにより、テキストフィールドの高さが自動的に変更されます。 – Willeke