Instance Method インスタンスメソッド

drawWithRect:options:attributes:

Draws the receiver with the specified options and other display characteristics of the given attributes, within the specified rectangle in the current graphics context. レシーバをこの指定されたオプションとこの与えられた属性の他の表示特徴とともに、現在のグラフィクス文脈においてこの指定された矩形内に描画します。

Declaration 宣言

- (void)drawWithRect:(NSRect)rect 
             options:(NSStringDrawingOptions)options 
          attributes:(NSDictionary<NSAttributedStringKey, id> *)attributes;

Parameters パラメータ

rect

The rectangle in which to draw the string. その中に文字列が描画されることになる矩形。

options オプション

String drawing options. 文字列描画オプション。

attributes

A dictionary of text attributes to be applied to the string. These are the same attributes that can be applied to an NSAttributedString object, but in the case of NSString objects, the attributes apply to the entire string, rather than ranges within the string. 文字列に適用されることになるテキスト属性からなる辞書。NSAttributedStringオブジェクトに適用されることができるのと同じ属性があります、しかしNSStringオブジェクトの場合には、属性は文字列全体に適用されます、文字列内の範囲ではなく。

Discussion 議論

This method works in single-line, baseline rendering configuration by default. That is, the rect argument's origin field specifies the rendering origin, and that point is interpreted as the baseline origin by default. If the string drawing option NSStringDrawingUsesLineFragmentOrigin is specified, origin is interpreted as the upper left corner of the line fragment rectangle, and the method behaves in multiline configuration. このメソッドは単一の行において、ベースラインレンダリング構成設定で初期状態では働きます。すなわち、rect引数の持つoriginフィールドは、描画原点を指定します、そしてそのポイントはベースライン原点として省略時では解釈されます。文字列描画オプションNSStringDrawingUsesLineFragmentOriginが指定されるならば、originは行断片矩形の上左隅として解釈されます、そしてメソッドは複数行構成設定で行動します。

The size field specifies the text container size. The width part of the size field specifies the maximum line fragment width if larger than 0.0. The height defines the maximum size that can be occupied with text if larger than 0.0 and NSStringDrawingUsesLineFragmentOrigin is specified. If NSStringDrawingUsesLineFragmentOrigin is not specified, height is ignored and considered to be single-line rendering (NSLineBreakByWordWrapping and NSLineBreakByCharWrapping are treated as NSLineBreakByClipping). sizeフィールドは、テキストコンテナの大きさを指定します。sizeフィールドのwidth部分は、最大限の行断片幅を指定します、もし0.0より大きいならば。heightは、テキストで占められる最大限の大きさを指定します、もし0.0より大きくそしてNSStringDrawingUsesLineFragmentOriginが指定されるならば。NSStringDrawingUsesLineFragmentOriginが指定されるならば、高さは無視されます、そして単一行を描出するよう考慮されます(NSLineBreakByWordWrappingNSLineBreakByCharWrappingNSLineBreakByClippingとして扱われます)。

You should only invoke this method when there is a current graphics context. あなたは、現在のグラフィック文脈がある場合にこのメソッドを発動するだけであるべきです。

See Also 参照

Deprecated 非推奨