Completely transparent views (opacity 0.0) don't receive touch events

Thanks Hank, good to know! :-)



you're not missing anything there

Actually, I did. I was thinking to complicated by animating 'opacity' for hiding/revealing a CALayer. That's exactly what's its 'hidden' property is for.




Am 24.07.2009 um 02:41 schrieb Hank Heijink (Mailinglists):

Completely transparent views (opacity 0.0) don't receive touch events - you're not missing anything there. As you have found, a little opacity is enough to catch them again. Depending on what's in your view, you might be able to set the background color to [UIColor clearColor] to get the same effect. Or, maybe you can replace the view you're hiding with another (empty) one that has a transparent background color.

I'm not sure what will work for you without knowing more, but there are ways to accomplish what you're trying to do.

Good luck,
Hank

On Jul 23, 2009, at 10:49 AM, Sebastian Morsch wrote:

Hi,

I *KNOW* this must be something absolutely stupid I'm missing, but I'm stuck with this:

I have an UIView that's supposed to display an explanatory overlay image whenever it's touched. When the user lifts the finger, the overlay should fade away. To accomplish this I do the following Inside my OverlayView's init method:

self.layer.contents = (id)[UIImage imageNamed:@"overlay.png"] CGImage];
self.layer.opacity = 0.0;

and then, inside the touchBegan: and touchEnded: methods I set the opacity to 1.0 and 0.0 respectively.

Now, this doesn't work at all, the view doesn't receive the touchBegan: and touchEnded: methods. But everything works fine if I set the opacity to 0.1 instead of 0.0!! And for instance, when I do this:

1. set opacity to 0.1 in the init call...
2. set opacity to 1.0 in the touchBegan call...
3. set opacity to 0.0 (!!!) in the touchEnded call...

all subsequent touches are ignored, touchBegan:, touchEnded:, etc. are never called again.


Any help on this is very very much appreciated!
Thanks, Sebastian

_______________________________________________

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/hank.list%40runbox.com

This email sent to hank.l...@runbox.com



_______________________________________________

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