lukech lukech - 5 months ago 12
iOS Question

UIView 'falling rain' transparent overlay that can be clicked through?

I'd like to create a

UIView
which will animate falling rain, which should be above all other views, at the very front, but transparent, and it shouldn't register taps or interaction at all, so tapping the UI behind it should behave exactly as it does now, before I've implemented it. It'd act as an overlay, and nothing more.

Is this as simple as setting
UserInteractionEnabled
to
NO
, or is there more to it? Do I need to subclass
UIView
, or override something, etc.?

d.g d.g
Answer

Yes, set userInteractionEnabled = NO; No need to subclass UIView. e.g.:

UIView *overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
overlay.backgroundColor = [UIColor colorWithWhite:0 alpha:.5];
[self.view addSubview:overlay];
Comments