Re: How do I size a NSView to fit an NSImage?
Re: How do I size a NSView to fit an NSImage?
- Subject: Re: How do I size a NSView to fit an NSImage?
- From: "Alan Smith" <email@hidden>
- Date: Thu, 27 Jul 2006 09:52:03 -0400
Shoot!!! I didn't mean to send it twice. GMail wasn't responding so I
didn't think it had been sent already.
I'm really really sorry.
On 7/27/06, Alan Smith <email@hidden> wrote:
Hello everyone,
I have code like this in an NSView subclass:
NSSize size = [self bounds].size;
NSLog(@"%i", size.height);
size.height = [pattern size].height;
NSLog(@"%i", size.height);
[self setBoundsSize: size];
'pattern' is an NSImage, width = 1px height = 16px. I drew it in PS so
I now the dimensions. With the above code I want to shrink the view
down to the height of the image but, not the width. This image will
change so I don't want to hard code 16 in there.
When I run this code I get huge numbers in the output:
1079033856 the first time and,
1077542912 the second time.
Obviously there is something very wrong.
I ran it again but changed one of the NSLogs. This time I wanted the
height of just the image, it printed:
1077542912
This I don't understand. The image is not that tall.
Let me explain what I am trying to create and perhaps you have a
better way to do it.
I'm making a bar that will be filled with a pattern image. I want it
the height of the image but, since this will be a pattern, I don't
want it 1px wide. And… that is pretty much it. Nothing else will be
done to this view except it will draw several buttons on top of this
patterned background.
Thanks for all help, Alan
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
--
// Quotes from yours truly -------------------------
"You don't forget, you just don't remember."
"Maturity resides in the mind."
"Silence is the Universe's greatest gift."
"Don't waste your life doing things others have already done."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden