macOS/iOS API解説

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

目次

sizeWithAttributes:

INDEX>AppKit>NSString Addtion

指定した属性でのレシーバのバウンディングボックスのサイズを返します
-(NSSize)sizeWithAttributes:(NSDictionary *)attributes

アイリスオーヤマ 家具転倒防止伸縮棒M KTB-40 ホワイト KTB-40

アイリスオーヤマ 家具転倒防止伸縮棒M KTB-40 ホワイト KTB-40

解説

指定した属性でのレシーバのバウンディングボックスのサイズを返します。

返り値

( NSSize )

サイズ

引数

( NSDictionary * )attributes

属性の辞書

フレームワーク

ApplicationKit

クラス

NSString Additions

Instance Methods

使用可能

10.0

参照

例文

#import "SetImage.h"

@implementation SetImage

- (IBAction)set:(id)sender

{
NSSize size;
NSString *aString;
      aString = @"sssssss";
      //imageを描画対象にする
        [image lockFocus];
        //[fnt set];
        //描画対象にimg2を合成する
        [aString drawInRect:NSMakeRect(0,0,100,100) withAttributes:nil];
        //imgを描画から外す
        [image unlockFocus];  
        
size = [aString sizeWithAttributes:nil];
NSLog([NSString stringWithFormat:@"%.1f,%.1f",size.width,size.height]);

}

@end