There are several ways to accomplish this.

(I'll note that you can get the size of an attributed string using its
-size method.)

Option 1: Create an NSImage with the size returned from the attributed
string. Draw the attributed string into the image. Create an NSColor
pattern from the image, using colorWithPatternImage:. Fill the rect
using [color set] and NSRectFill()/NSRectFillUsingOperation().

Option 2: you could alternatively go the slightly lower-level Core
Graphics route, and use CGContextDrawTiledImage(), which will draw a
tiled CGImage. I'm using this method in my personal code. I can't
remember why at the moment, but I may have run into limitations with
option 1. (Of course, I'd definitely try option 1 first as it'll be
easier.)

David
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to