3

好吧,我得到了这个:http ://d.pr/i/jItM

我显然想将文本向下移动并远离左边缘。我有 NSTextField 的子类,我在其中绘制背景,但我无法找到这个。

4

1 回答 1

5

知道了。两者都需要被覆盖。

- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent
{
    aRect.origin.y += 9;
    aRect.origin.x += 10;
    [super editWithFrame:aRect inView:controlView editor:textObj delegate:anObject event:theEvent];
}

- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength
{
    aRect.origin.y += 9;
    aRect.origin.x += 10;
    [super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
}
于 2012-11-22T14:15:53.360 回答