Usted podría subclase NSTextFieldCell
a hacer lo que quiera:
MDVerticallyCenteredTextFieldCell.h:
#import <Cocoa/Cocoa.h>
@interface MDVerticallyCenteredTextFieldCell : NSTextFieldCell {
}
@end
MDVerticallyCenteredTextFieldCell.m:
#import "MDVerticallyCenteredTextFieldCell.h"
@implementation MDVerticallyCenteredTextFieldCell
- (NSRect)adjustedFrameToVerticallyCenterText:(NSRect)frame {
// super would normally draw text at the top of the cell
NSInteger offset = floor((NSHeight(frame) -
([[self font] ascender] - [[self font] descender]))/2);
return NSInsetRect(frame, 0.0, offset);
}
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView
editor:(NSText *)editor delegate:(id)delegate event:(NSEvent *)event {
[super editWithFrame:[self adjustedFrameToVerticallyCenterText:aRect]
inView:controlView editor:editor delegate:delegate event:event];
}
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView
editor:(NSText *)editor delegate:(id)delegate
start:(NSInteger)start length:(NSInteger)length {
[super selectWithFrame:[self adjustedFrameToVerticallyCenterText:aRect]
inView:controlView editor:editor delegate:delegate
start:start length:length];
}
- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)view {
[super drawInteriorWithFrame:
[self adjustedFrameToVerticallyCenterText:frame] inView:view];
}
@end
A continuación, puede utilizar un habitual NSTextField
en Interface Builder y especifique MDVerticallyCenteredTextFieldCell
(o lo que sea que quiera nombrar) como la clase personalizada para el texto f celda de campo de texto de ield (seleccione el campo de texto, hacer una pausa, a continuación, haga clic en el campo de texto de nuevo para seleccionar la celda dentro del campo de texto):

cheque esta respuesta también: http://stackoverflow.com/a/39945456/73195 – Hejazi