Pbk Pbk - 2 years ago 75
Swift Question

Create an invisible view that is interactable in swift

For prototyping I am looking to create a invisible interaction area.

  • If I set the alpha to 0, you can't interact withit.

  • If you set it to
    hidden, it also does not receive gesture events.

Answer Source

Why do you want to use a View for this, Instead you could just use a UIButton and set frame to your current view's frame & set its background color to clearColor like below,

self.invisibleButton.backgroundColor = [UIColor clearColor];

This will do the same action & reduce little works like adding Tap gesture and setting some properties for the view if you go with View.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download