On May 11, 2008, at 1:26 AM, Michael Vannorsdel wrote:

On May 11, 2008, at 1:03 AM, Patrick J. Collins wrote:

Does anyone happen to know how one could set the opacity of an
NSImageView object? I am looking for a way to simply fade in an image
on within my app's window-- but neither of the NSImageView nor
IKImageView list anything about opacity...


NSView and subclasses have a setAlphaValue: that might do what you want. It requires a backing Core Animation layer (CALayer) and therefore is Leopard only. You can have IB setup the layer backing by setting the view's Wants Core Animation Layer under Effects of the Inspector window; I think Content View is the one to enable it on. You can do it programatically with setWantsLayer:YES as well. Then you use the animator proxy like:

[[NSAnimationContext currentContext] setDuration:2.0]; //2 second fade [[imageView animator] setAlphaValue:1.0f]; //fade in view to full opacity

Alternately you can subclass the NSImageView or make your own NSView subclass and override drawRect: to vary the drawn image's opacity. If you're adventurous you can use Core Image to do an accelerated fade for Tiger and up.

Or, for the particular case of fading in and out, you can always use NSViewAnimation: http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSViewAnimation_Class/Reference/Reference.html

-> jp

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to