drawAtPoint:
指定位置に属性付き文字を描画します
-(void)drawAtPoint:(NSPoint)point:
解説
指定位置に属性付き文字を描画します
描画するViewをフォーカスしておきます。
返り値
( void )
なし
引数
( NSPoint )point
位置
フレームワーク
ApplicationKit
クラス
NSAttributedStringAdditions
Instance Methods
使用可能
10.1
参照
- lockFocus (NSView)
- size
- drawInRect:
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender {//開けるファイル拡張子の配列 NSArray *fileTypes = [ NSArray arrayWithObject : @"rtf" ]; //OpenPanelを作る NSOpenPanel *opPanel = [ NSOpenPanel openPanel ]; NSAttributedString *aString; //OpenPanelの結果のボタン番号 int opRet; NSData *data; //OpenPanelでファイル選択 opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Documents" //どのどのファイルを選択しておくか types : fileTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら aString = [[NSAttributedString allocWithZone:[self zone]] initWithPath:[opPanel filename] documentAttributes:NULL]; [image lockFocus]; [aString drawAtPoint:NSMakePoint(0,1)]; [image unlockFocus]; } } @end