1

NSTextFieldが使用している行フラグメントのパディングを知るにはどうすればよいですか?

4

1 に答える 1

-1

-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);
于 2012-07-21T11:26:01.160 に答える