我怎么知道NSTextField使用的线段填充?
答案 0 :(得分:0)
您可以将-lineFragmentPadding
用于NSTextField's textContainer
。像这样:
float lineFragmentPadding = [textContainer lineFragmentPadding];
例如:
NSSize textFieldSize = [textFieldOutlet frame].size;
NSTextStorage *textStorage = [[[NSTextStorage alloc] initWithAttributedString:[textFieldOutlet attributedStringValue]] autorelease];
NSTextContainer *textContainer = [[[NSTextContainer alloc] initWithContainerSize:NSMakeSize(textFieldSize.width, textFieldSize.height)] autorelease];
NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease];
[layoutManager addTextContainer:textContainer];
[textStorage addLayoutManager:layoutManager];
[layoutManager glyphRangeForTextContainer:textContainer];
float lineFragmentPadding = [textContainer lineFragmentPadding];
NSLog(@"Padding: %f", lineFragmentPadding);