Frage

I have a UIView that partially cover some contents and I would like apply a blur effect exactly like the iOS Notification Center.

I'm not looking for a way to apply blur on UIImage, but on UIView with other contents (UIView, UIButton, ecc) under it.

enter image description here

Ideas ? Thanks.

War es hilfreich?

Lösung 2

myView.backgroundColor = [UIColor clearColor];
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:myView.frame];
bgToolbar.barStyle = UIBarStyleDefault;
[myView.superview insertSubview:bgToolbar belowSubview:myView];

just past from an other answer how ever i use toolbar in my projects and works perfect, i am using alpha=0.98 enter image description here

Andere Tipps

First change the UIView into an UIImage. You can use the following as a category of UIView.

@implementation UIView (ConvertToUIImage)

- (UIImage *)asImage {
    NSAssert(self, @"Do not use this method on nil instance of UIView.");
    if (!self) return 0;

    UIGraphicsBeginImageContextWithOptions(self.frame.size, YES, 0);
    [self drawViewHierarchyInRect:self.frame afterScreenUpdates:NO];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    NSAssert(image, @"Image must not be nil at this point.");
    return image;
}

@end

Next you need to blur the UIImage, there is a related question here Creating a blur effect in iOS7

Finally, use the UIImage as a background.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top