UIVisualEffectView renders differently on differen

2019-06-14 23:31发布

问题:

In my ViewController.swift:

var img = UIImageView(image: UIImage(named: "puddles"))

img.frame = view.bounds;
view.addSubview(img);


var effect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var effectView = UIVisualEffectView(effect: effect)
effectView.frame = CGRectMake(0, 0, 500, 500)
view.addSubview(effectView)

The image as rendered using the code above in the iPad Air, iPhone 5, or iPhone 5S simulators:

The image as rendered using the code above in the iPhone 4S, iPad 2, or iPad Retina simulators:

Note: Both images above were taken from the simulator, but this can be reproduced on actual devices running iOS 8 Beta 1 as well.

Obviously, I would like to achieve the first effect on all devices. How can I achieve the same first effect on all devices?

回答1:

UIVisualEffectView in iOS 8 does pretty much the same thing as the (formerly private API) translucency and vibrancy effects seen in iOS 7. Like the iOS 7 effects, they fall back to graphically simpler implementations on hardware that can't render such complex graphics effects in realtime.



回答2:

We hit this issue recently when our Visual Effect View was an ugly grey color on one of our developer's machines.

UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];

It turns out that they had enabled Low Quality Graphics Override on their iOS Simulator. Turning this option back to Device Default fixes the issue and displays a nice translucent view.

iOS Simulator > Menu Bar > Debug > Graphics Quality Override > Device Default



标签: ios swift ios8