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
CustomWindowwhich is a subclass ofUIWindow. After that replacing defaultwindowofUIApplicationwithCustomWindow, create a newrootViewControllerfor my new window. - In
CustomWindow, I have anoverlay(is anUIView).Overlayhave light gray color with an alpha and every event onoverlaywill be pass through to below view. - Whenever
CustomWindowadd a new subview, i will bringoverlayto front. It's make sureoverlaywill 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
UIActivityViewControlleror click onCancel Button,UIActivityViewControlleris dismissed normally.If i change color of
overlaytoclearColor, it works fine too.
My question is
How can i touch on extensions when i have
overlayon window andoverlayhave 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.