Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-26-2010, 04:45 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 14
snowffer is on a distinguished road
Question what's the difference between alpha=0 and hidden=YES?

Hello, everyone

I want to put a UIView as a subview to the toppest of all the other subviews. And I want to let this UIView be totally transparent and also let this UIView receive some input events such as slipping over its surface. So I set its alpha to Zero. It is totally transparent after that but the strange thing is it can't receive any input events. And if I tap it, the other UIViews below it would receive the tap event. It seems that the UIView whose alpha=0 disappears or hides. If that's true, I wonder that what's the difference between alpha=0 and hidden=YES?!!! How could it be?!! If alpha=0 and hidden=YES are the same, why do we need property hidden?

If anyone could give me an answer to this question or tell me another way to let a UIView be transparent and receive some input events at the same time, I'll appreciate him/her very much.

Also thank the guys who come in to read my question.

BTW, the UIView can receive events when its alpha value equals or more than 0.02. But I can't let it be 0.02 because of some reasons. I want it to be Zero.

Last edited by snowffer; 11-26-2010 at 05:07 AM.
snowffer is offline   Reply With Quote
Old 11-26-2010, 06:58 AM   #2 (permalink)
57Digital Ltd, Mobile Dev
iPhone Dev SDK Supporter
 
iPhoneConnection's Avatar
 
Join Date: Apr 2010
Location: Sheffield
Posts: 144
iPhoneConnection is on a distinguished road
Default

You're assuming all controls have an alpha attribute. They don't.
iPhoneConnection is offline   Reply With Quote
Old 11-26-2010, 07:49 AM   #3 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by snowffer View Post
Hello, everyone

I want to put a UIView as a subview to the toppest of all the other subviews. And I want to let this UIView be totally transparent and also let this UIView receive some input events such as slipping over its surface. So I set its alpha to Zero. It is totally transparent after that but the strange thing is it can't receive any input events. And if I tap it, the other UIViews below it would receive the tap event. It seems that the UIView whose alpha=0 disappears or hides. If that's true, I wonder that what's the difference between alpha=0 and hidden=YES?!!! How could it be?!! If alpha=0 and hidden=YES are the same, why do we need property hidden?

If anyone could give me an answer to this question or tell me another way to let a UIView be transparent and receive some input events at the same time, I'll appreciate him/her very much.

Also thank the guys who come in to read my question.

BTW, the UIView can receive events when its alpha value equals or more than 0.02. But I can't let it be 0.02 because of some reasons. I want it to be Zero.

I believe that Cocoa Touch treats and alpha less than .02 as also being hidden, since below that alpha level it's invisible, and Apple's engineers decided that invisible controls should not be clickable.

Using an alpha value requires that the graphics hardware blend each pixel from the object with everything underneath. It's compute-intensive. The hidden flag, on the other hand, is a switch. If you turn it on, the OS knows it doesn't have to draw the object at all.

In order to do what you're trying to do you might have to leave the object's alpha value as 1, but set the alpha value of all of its pixels to zero. (Set it's background color to [UIColor clearColor] and don't give it any contents. That should enable it to receive events, but still be invisible.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

Tags
alpha, hidden

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 375
7 members and 368 guests
HemiMG, Kirkout, MarkC, Sami Gh, SamorodovAlex, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:46 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0