macOS/iOS API解説

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

目次

boundingRectForFont

レシーバーのバウンディングボックスを返します

解説

レシーバーのバウンディングボックスを返します。

返り値

( NSRect )

矩形

引数

フレームワーク

ApplicationKit

クラス

NSFont

Instance Methods

使用可能

10.0

参照

- boundingRectForGlyph:

例文

#import "MyView.h"

//MyViewはNSViewのサブクラス
@implementation MyView

-(void)drawRect:(NSRect)rect
{

	NSFont *font =[NSFont boldSystemFontOfSize:50.0];
	NSLog([font fontName]);
	NSBezierPath *thePath = [NSBezierPath bezierPath];
	NSGlyph glyphID[11]={43,72,79,79,82,04,58,82,85,79,71};
			
			[thePath moveToPoint:NSMakePoint(10,10)];
			[thePath appendBezierPathWithGlyphs:&glyphID[0]
										count:11
										inFont:font
											];
			[[NSColor blueColor] set];
			[thePath fill];
			
			NSRect glyphRect = [font boundingRectForFont];
			NSLog(@"%f,%f-%f,%f",glyphRect.origin.x,glyphRect.origin.y,glyphRect.size.width,glyphRect.size.height);			
}

@end