我意识到我可以以编程方式添加 UIVisualEffects,如果类存在,则有条件地执行,例如。
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;
}
但是有没有办法在情节提要中添加视觉效果视图,然后有条件地删除它们以与 iOS7 兼容?我试过这个,但一直收到这个错误: iOS8 之前的 Class Unavailable UIVisualEffectView