I have found information that says you need to subclass NSTextfieldCell
but every example, while it does in fact vertically align the text, it does not draw the specified background, borders etc… If I removed the subclass cell, the rest draws correctly
Sorry dunno why that would be the case
Docs sure dont indicate that you have to do all those things for yourself
class VerticallyCenteredTextFieldCell: NSTextFieldCell {
func adjustedFrame(toVerticallyCenterText rect: NSRect) → NSRect {
var titleRect = super.titleRect(forBounds: rect)
let minimumHeight = self.cellSize(forBounds: rect).height
titleRect.origin.y += (titleRect.height - minimumHeight) / 2
titleRect.size.height = minimumHeight
return titleRect
}
override func drawInterior(withFrame cellFrame: NSRect, in controlView: NSView) {
super.drawInterior(withFrame: adjustedFrame(toVerticallyCenterText: cellFrame), in: controlView)
}
override func draw(withFrame cellFrame: NSRect, in controlView: NSView) {
super.draw(withFrame: cellFrame, in: controlView)
}
}
Try this…
well sadly that is EXACTLY what I have tried