UIVibrancyEffect is darkened on the device, bright in the simulator

I experience a bad vibration effect on my iPhone 6.

Here's what it looks like: simulator vs. device

I checked the value of UIAccessibilityIsReduceTransparencyEnabled() and returns false on both the device and the simulator.

The code for the background image, effects and the View container that I add, all the other elements look like this:

 import Foundation import UIKit import PureLayout class BackgroundImageView : UIView { let bgImage = UIImageView(forAutoLayout: ()) var blurView:UIVisualEffectView! var vibrancyView:UIVisualEffectView! var containerView: UIView? = nil { willSet(container) { vibrancyView.contentView.addSubview(container!) } } init(imageName: String) { super.init() let screenSize: CGRect = UIScreen.mainScreen().bounds bgImage.image = UIImage(named: imageName) // Scale relative to the size of the iPhone 6 Plus: http://martinnormark.com/smooth-transition-from-launch-image-to-view-controller-in-ios/ bgImage.transform = CGAffineTransformMakeScale(screenSize.width / 414, screenSize.height / 736) self.addSubview(bgImage) let blurEffect = UIBlurEffect(style: .Dark) self.blurView = UIVisualEffectView(effect: blurEffect) self.blurView.setTranslatesAutoresizingMaskIntoConstraints(false) self.addSubview(blurView) let vibrancyEffect = UIVibrancyEffect(forBlurEffect: blurEffect) vibrancyView = UIVisualEffectView(effect: vibrancyEffect) vibrancyView.setTranslatesAutoresizingMaskIntoConstraints(false) blurView.contentView.addSubview(vibrancyView) } override init(frame: CGRect) { super.init(frame: frame) } required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override func updateConstraints() { super.updateConstraints() bgImage.autoCenterInSuperview() containerView?.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero) blurView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero) vibrancyView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero) } } 
+8
ios iphone ios8 swift
source share
3 answers

It is possible that UIAccessibilityDarkerSystemColorsEnabled() returns true for your iPhone 6 or iPhone 6 plus, so it looks darker.

To disable it, go to "Settings" β†’ "General" - "Accessibility" β†’ "Increase contrast" β†’ "Dark colors" to switch from it.

Edit

As stated in UIVibrancyEffect .

The effect of vibration depends on the color. Any subtypes that you add to the contentView should implement the tintColorDidChange method and update yourself accordingly. UIImageView objects with images that have the UIImageRenderingModeAlwaysTemplate rendering mode, as well as UILabel objects, will be updated automatically.

We must use images with the UIImageRenderingModeAlwaysTemplate rendering UIImageRenderingModeAlwaysTemplate to automatically update UIImageView objects. Applying this makes the UIVibrancyEffect shortcut on the iPhone device.

+3
source share

I'm not sure, but I used var instead of let in the lines below, and it worked for me.

 var vibrancyEffect = UIVibrancyEffect(forBlurEffect: blurEffect) 

Perhaps this will help you.

I used it like this.

 var vibrancyEffect = UIVibrancyEffect(forBlurEffect: blurEffect) var vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect) vibrancyEffectView.frame = view.bounds 
0
source share

Use shared RGB, not sRGB or an RGB device.

0
source share

All Articles