Author Topic: Invisible UIButton that can still be clicked  (Read 3083 times)

bach

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 6
    • View Profile
Invisible UIButton that can still be clicked
« on: August 21, 2014, 08:09:54 AM »
I need to setup an invisible UIButton that when pressed,
I display a sprite to show that it's been touched.

When I set the Alpha to 0 in Colors > Normal
The click event no longer fires.

Is there a way to have the
Normal Sprite transparent
Pressed Sprite Visible
and still have the Click event firing?

thanks




kobilica

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Invisible UIButton that can still be clicked
« Reply #1 on: August 21, 2014, 08:45:22 AM »
Set alpha to 1, it won't be visible but it will work :)

slumtrimpet

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 13
    • View Profile
Re: Invisible UIButton that can still be clicked
« Reply #2 on: August 21, 2014, 11:57:38 AM »
alpha == .001 should still fire event and be invisible

kobilica

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Invisible UIButton that can still be clicked
« Reply #3 on: August 21, 2014, 12:18:26 PM »
Oh correct, I forgot alpha is from 0 - 1.. I am used to 0 - 255

bach

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 6
    • View Profile
Re: Invisible UIButton that can still be clicked
« Reply #4 on: August 21, 2014, 05:49:06 PM »
Thanks guys, you're both right.

In my case i have set the Alpha for the Normal Color to 1 (hex color)
that made it invisible and still picked up the touch. Thanks for the tip

For the pressed State I kept it's Color Alpha to 255
works great thanks again!