Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class Unavailable UIVisualEffectView prior to iOS8

I realize that I can add UIVisualEffects programmatically, conditionally executed if the class exists, eg.

if([UIVisualEffectView class]){

        UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
        UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
        [blurEffectView setFrame:self.backgroundBlurView.bounds];

        [self.backgroundBlurView addSubview:blurEffectView];

        UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
        UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
        [vibrancyEffectView setFrame:self.backgroundVibrancyView.bounds];

        [[vibrancyEffectView contentView] addSubview:self.backgroundVibrancyView];

        [[blurEffectView contentView] addSubview:vibrancyEffectView];
        vibrancyEffectView.center = blurEffectView.center;
    }

But is there a way to add the visual effects views in the storyboard, then conditionally remove them in order to be compatible with iOS7? I tried this but keep getting this error: Class Unavailable UIVisualEffectView prior to iOS8

like image 215
Tyler Martin Avatar asked Nov 11 '22 00:11

Tyler Martin


1 Answers

Nope. you can change your deployment target to iOS 8+ to kill the error though:

like image 193
amleszk Avatar answered Dec 04 '22 22:12

amleszk