Re: Text over graphics
Re: Text over graphics
- Subject: Re: Text over graphics
- From: "John C. Randolph" <email@hidden>
- Date: Fri, 28 Sep 2001 06:31:12 -0700
On Friday, September 28, 2001, at 12:54 AM, Angela Brett wrote:
Hi,
This is probably quite a simple thing to do, but I can't figure out how
to do it. Basically I want to have some text over top of a bunch of
composited images I've already drawn, and I want the text to be able to
change.
I've tried doing this with NSTextFields and by drawing an NSString, but
with both I get the same problem. If I don't specify a background
colour (NSString) or setDrawsBackground:NO (NSTextField) then I can see
the image behind it, which is what I want, but when the text changes
the old text stays there underneath it. I would expect that to happen
with drawing an NSString, but not really with an NSTextView.
When you change the text, you'll need to re-draw the background image,
too. If I were doing this, I'd take an approach like:
@interface TextAndImageView: NSImageView
{
NSAttributedString *theString;
}
- drawRect:(NSRect) rect
{
[super drawRect:rect]; // this draws the image
[theString drawAtPoint:NSMakePoint(10,10)]; // you may want it drawn
somewhere else..
}
-jcr
"I fear all we have done is to awaken a sleeping giant and fill him with
a terrible resolve." -Admiral Isoroku Yamamoto, Dec 7, 1941.