我想制作 NSTextView 点边框,我的 drawRect: 代码如下
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
CGFloat lineDash[2];
lineDash[0] = 1.0;
lineDash[1] = 1.0;
NSBezierPath *path = [NSBezierPath bezierPathWithRect:self.bounds];
[path setLineDash:lineDash count:2 phase:0.0];
[path stroke];
}
我也想在文本和边框之间留出一些边距,我的代码如下
[textView setTextContainerInset:NSMakeSize(0, 10.0)];
[textView setString:@"This is a testThis is a testThis is a testThis is a test"];
但结果是顶部边框丢失,谁知道如何解决这个问题?