我意识到我可以通过编程方式添加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之前的类不可用UIVisualEffectView
答案 0 :(得分:1)
不。您可以将部署目标更改为iOS 8+以消除错误: