make uiview transparent without having the uiview's buttons transparent

Discussion in 'iOS Programming' started by johnmerlino, May 30, 2012.

  1. johnmerlino macrumors member

    Joined:
    Oct 22, 2011
    #1
    Hey all,

    Im using storyboard on xcode 4. I created a uiview and put 4 buttons on it. Now I want the uiview to be transparent but the buttons remain visible. Problem is when I set alpha of uiview to 0, the buttons become invisible as well.

    thanks for response
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    So what should be visible behind/around the UIButtons? Why not just make your UIButtons subviews of whatever is around them?
     
  3. johnmerlino thread starter macrumors member

    Joined:
    Oct 22, 2011
    #3
    because I want to make the buttons reusuable since i have four uiviews that can display depending on a type selected. They all have unique buttons but certain buttons will be reused. Hence, I want a transparent ui view with visible buttons.

    Is this possible?
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Don't set the alpha to 0. Set the background color to clearColor.
     
  5. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #5
    You can just go in Interface Builder, and set the opacity of the background color to 0, so then it's gone. Or like Dejo said, set the background color to [UIColor clearColor];
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    You can set the background to clearColor using Interface Builder, as well, using the color picker drop-down (as seen in the following screenshots):
     

    Attached Files:

  7. johnmerlino thread starter macrumors member

    Joined:
    Oct 22, 2011
    #7
    thanks for responses but now I have a new problem. The buttons behind the transparent uiview seem to be not clickable, as if the transparent uiview is blocking it from being clicked.
     
  8. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #8
    Thanks Dejo for the screenshot :) I was too lazy to do it. Basically, setting the opacity is the same thing, so i thought it was easier to explain.

    Next for your question, not 100% sure what the issue is. Do you have something else in that view, something laying over it, accidently pressed the "enable user interaction"?

    Gz
     

Share This Page