0

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.
Pbk
  • 2,004
  • 14
  • 11
  • How about _not_ creating the view and just tracking the gesture? As soon as you want to show it you can create it at the position you have tracked. – Darko Apr 21 '16 at 07:26

3 Answers3

3

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.

Bharath
  • 2,064
  • 1
  • 14
  • 39
0

The best solution I have found is to set the background color to an invisible color. You can't see the button but you can interact with it.

In the init I put:

self.backgroundColor = UIColor.blueColor().colorWithAlphaComponent(0)

Is there any better way to do this?

Pbk
  • 2,004
  • 14
  • 11
0

Create a UIView enable userInteraction and make clear background color

UIView *viewsample=[[UIView alloc]init];
viewsample.frame= CGRectMake(0, 0, 200, 200);
viewsample.backgroundColor= [UIColor clearColor];
viewsample.userInteractionEnabled=YES;
[self.view addSubview:viewsample];

UITapGestureRecognizer *tapSkip = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(iviewsampleClicked:)];
[viewsample addGestureRecognizer:tapSkip];

method called when it touched

-(void)iviewsampleClicked:(UIGestureRecognizer*)gesture{

}
Jagveer Singh
  • 2,258
  • 19
  • 34