The text inside NSTextField
gets cut off when I have the font changed to monospacedDigitSystemFont
.
I have the following code in the viewDidLoad
method. I do not understand why it has been cut off since sizeToFit
has been called and the intrinsic size should be used.
The label at the bottom looks fine and it is using the default system font.
labelTimeNow.sizeToFit()
labelTimeNow.font = NSFont.monospacedDigitSystemFont(
ofSize: labelTimeNow.font!.pointSize,
weight: .medium
)
labelTimeNow.stringValue = DCClock.getCurrentTimeInFormat("HH:mm")
Reference
Stupid me, I should call sizeToFit
after changing the font spacing.
labelTimeNow.font = NSFont.monospacedDigitSystemFont(
ofSize: labelTimeNow.font!.pointSize,
weight: .medium
)
labelTimeNow.stringValue = DCClock.getCurrentTimeInFormat("HH:mm")
labelTimeNow.sizeToFit()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.