I'm creating an overlay which will cover all displaying views on screen. This overlay always appears even in case rootViewController
changes, pushing or presenting.
My idea is
- Create
CustomWindow
which is a subclass ofUIWindow
. After that replacing defaultwindow
ofUIApplication
withCustomWindow
, create a newrootViewController
for my new window. - In
CustomWindow
, I have anoverlay
(is anUIView
).Overlay
have light gray color with an alpha and every event onoverlay
will be pass through to below view. - Whenever
CustomWindow
add a new subview, i will bringoverlay
to front. It's make sureoverlay
will be on the top in every case.
CustomWindow
@implementation CustomWindow
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_overlay = [[UIView alloc] initWithFrame:self.bounds];
_overlay.userInteractionEnabled = NO;
_overlay.backgroundColor = [UIColor lightGrayColor];
_overlay.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self addSubview:_overlay];
}
return self;
}
- (void)didAddSubview:(UIView *)subview {
[super didAddSubview:subview];
[self bringSubviewToFront:_overlay];
}
@end
Everything works fine in every case even when pushing, presenting or changing rootViewController
.
Problem
But when i show an UIActivityViewController
, I can't click on any extensions which are displayed on UIActivityViewController
.
Magically
When i click outside of
UIActivityViewController
or click onCancel Button
,UIActivityViewController
is dismissed normally.If i change color of
overlay
toclearColor
, it works fine too.
My question is
How can i touch on extensions when i have
overlay
on window andoverlay
have a color ?If i can't, can anyone tell me why it happens ? It's perfect when you can quote the reason from a document.
I'm pretty sure this doesn't relate to how i initialize UIActivityViewController
or the way i show UIActivityViewController
.
MORE
I found a problem quite similar to this problem on Android
. But i'm not sure because i haven't seen any official document about it from Apple. One more thing is when changing color to clearColor
can affect touch. So actually, i don't think they are same.