#import <Cocoa/Cocoa.h>
@interface TextFiledCellCenter : NSTextFieldCell
@property (nonatomic) IBInspectable CGFloat oringeY;
@end
#import "TextFiledCellCenter.h"
@implementation TextFiledCellCenter
- (NSRect)titleRectForBounds:(NSRect)rect
{
NSRect titleRect = [super titleRectForBounds:rect];
CGFloat minimHeight = self.cellSize.height;
titleRect.origin.y += (titleRect.size.height - minimHeight)/2;
titleRect.size.height = minimHeight;
return titleRect;
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
[super drawWithFrame:cellFrame inView:controlView];
}
- (void)selectWithFrame:(NSRect)rect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)delegate start:(NSInteger)selStart length:(NSInteger)selLength{
CGRect titleRect = [self titleRectForBounds:rect];
titleRect.origin.y += self.oringeY;
[super selectWithFrame:titleRect inView:controlView editor:textObj delegate:delegate start:selStart length:selLength];
}
@end