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

drawAtPoint:withAttributes:

Draws the receiver with the font and other display characteristics of the given attributes, at the specified point in the current graphics context. レシーバをこの与えられた属性のフォントと他の表示特徴とともに、現在のグラフィクス文脈においてこの指定された地点で描画します。

Declaration 宣言

iOS, iPadOS, Mac Catalyst, tvOS, watchOS

- (void)drawAtPoint:(CGPoint)point 
     withAttributes:(NSDictionary<NSAttributedStringKey, id> *)attrs;

macOS

- (void)drawAtPoint:(NSPoint)point 
     withAttributes:(NSDictionary<NSAttributedStringKey, id> *)attrs;

Parameters パラメータ

point

The point in the current graphics context where you want to start drawing the string. The coordinate system of the graphics context is usually defined by the view in which you are drawing. In AppKit, the origin is normally in the lower-left corner of the drawing area, but the origin is in the upper-left corner if the focused view is flipped. あなたが文字列の描画を始めたいところの、現在のグラフィック文脈での地点。グラフィック文脈の座標系は、そこにおいてあなたが描画しているビューによって通常は定義されます。AppKitにおいて、原点はふつう描画エリアの下側左隅になります、しかしこの原点は、フォーカスされたビューがフリップされるならば上側左隅になります。

attrs

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 議論

The width (height for vertical layout) of the rendering area is unlimited, unlike drawInRect:withAttributes:, which uses a bounding rectangle. As a result, this method renders the text in a single line. However, if newline characters are present in the string, those characters are honored and cause subsequent text to be placed on the next line underneath the starting point. レンダリング領域の幅(垂直レイアウトに対する高さ)は無制限です、drawInRect:withAttributes:とは違い、それは境界矩形を使います。結果として、このメソッドはテキストを単一の行に表します。しかしながら、改行文字が文字列において提示されるならば、それら文字は尊重されてその後のテキストが次の行上で開始地点の真下に置かれるようにします。

There must be either a focused view or an active graphics context when you call this method. あなたがこのメソッドを呼び出す場合、フォーカスされたビューまたはある実際のグラフィックコンテキストのどちらかがなければなりません。

See Also 参照

Sizing and Drawing Strings 文字列の大きさ指定と描画