macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

setLineFragmentRect:forGlyphRange:usedRect:

行分割をセットします
-(void)setLineFragmentRect:(NSRect)fragmentRect:
         forGlyphRange:(NSRange)glyphRange:
         usedRect:(NSRect)usedRect:

解説

行分割をセットします。

返り値

( void )

なし

引数

( NSRect )fragmentRect

ラインフラグメント矩形

( NSRange )glyphRange

グリフ範囲

( NSRect )usedRect

矩形

フレームワーク

ApplicationKit

クラス

NSLayoutManager

Instance Methods

使用可能

10.0

参照

- lineFragmentRectForGlyphAtIndex:effectiveRange:
- lineFragmentUsedRectForGlyphAtIndex:effectiveRange:

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
//myOutletはTextView
NSTextContainer *textContainer;
NSLayoutManager *layM;
NSRect rect;
layM = [myOutlet layoutManager];
[myOutlet insertText:@"aaaaaaaaaaaaaa"];

textContainer = [layM textContainerForGlyphAtIndex:3 effectiveRange:nil];
[layM setLineFragmentRect:NSMakeRect(0,0,10,10)
                forGlyphRange:NSMakeRange(1,10)
                usedRect:NSMakeRect(0,0,10,10)
                ];

NSLog([NSString stringWithFormat:@"%.1f",rect.size.width]);

}

@end