I had a requirement, actually, not a requirement, for my project. The designer put a custom pop up in his design/layout for the app. It consists of a blur background. So I searched on Google about that. Found the answer on SO, as usual. But I just wanna share the direct approach to you anyway without reading all the answers and the discussions.
Apparently, this solution is not so clean, but also not prohibited to use by Apple. So we can safely say this is the easiest way or quickest way to implement a blurred background without using QuartzCore or any frameworks or libraries. We don't have to draw anything. Without further ado, this is the code:
// Apparently a dirty yet quite fine solution for blurring bg
self.view.backgroundColor = [UIColor clearColor];
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:self.view.frame];
bgToolbar.tag = 555;
bgToolbar.barStyle = UIBarStyleBlack;
[self.view addSubview:bgToolbar];
- (void)removeActivitiesPopup {
for (UIToolbar *toolbar in self.view.subviews) {
if ([toolbar isKindOfClass:[UIToolbar class]]) {
if (toolbar.tag == 555) {
NSLog(@"found toolbar 555");
[toolbar removeFromSuperview];
}
}
}
}
Pretty easy, right? If this post helped you, please share and subscribe! :) FIN.
Post a Comment