macOS/iOS API解説

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

目次

cellFrameForTextContainer:proposedLineFragment:glyphPosition:characterIndex:

調査中
-(NSRect)cellFrameForTextContainer:(NSTextContainer *)textContainer:
                    proposedLineFragment:(NSRect)lineFrag:
                    glyphPosition:(NSPoint)position:
                    characterIndex:(unsigned)charIndex:

解説

テキストアタッチメントセルのフレームを返します。

返り値

( NSRect )

矩形

引数

( NSTextContainer * )textContainer

テキストコンテナ

( NSRect )lineFrag

矩形

( NSPoint )position

位置

( unsigned )charIndex

フレームワーク

ApplicationKit

クラス

NSTextAttachmentCell

Instance Methods

使用可能

10.0

参照

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
    //テキストアタッチメント
    NSTextAttachment *theAttachment;
    NSRect rect;
    //ファイルラッパ
    NSFileWrapper *theWrapper = [[[NSFileWrapper alloc] initWithPath:
            [[NSBundle mainBundle] pathForResource:@"image" ofType:@"tiff"]] autorelease];
    //テキストアタッチメント
    theAttachment = [[[NSTextAttachment alloc] initWithFileWrapper:theWrapper] autorelease];
    //
    [[myOutlet textStorage] appendAttributedString:
            [NSAttributedString attributedStringWithAttachment:theAttachment]];
            
rect = [[theAttachment attachmentCell] cellFrameForTextContainer:[myOutlet textContainer] 
                    proposedLineFragment:NSMakeRect(0,0,50,50) 
                    glyphPosition:NSMakePoint(30,30) 
                    characterIndex:1 
                     ];

NSLog([NSString stringWithFormat:@"cellFrameForTextContainer %f,%f,%f,%f",rect.origin.x,rect.origin.y,rect.size.width,rect.size.height]);
         

}

@end