We have successfully integrated UIVibrancyEffect and UIVisualEffectView into our app, but I'm noticing that the vibrancy isn't as intense as I'd like and the text is more dim than the demos I've seen. I can't find any way to tweak this, or to affect it in any way. I thought it might be because we are using a custom font, but I tried that too and the font is thicker but still looks dim. Any ideas?
With our custom font Open Sans Light:
With system font:
Here is the code:
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[blurEffectView setFrame:self.viewController.view.bounds];
UIVisualEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
[vibrancyEffectView setFrame:self.viewController.view.bounds];
[blurEffectView.contentView addSubview:vibrancyEffectView];
UITextView *messageText = [[UITextView alloc] initWithFrame:CGRectMake(0,0,320,568)];
[messageText setFont:[CLAppearanceManager fontForLabelType:CLAppearanceLabelFontWaveMessageEntry]];
[messageText setTextColor:[UIColor whiteColor]];
messageText.layer.shadowColor = [[UIColor blackColor] CGColor];
messageText.layer.shadowOffset = CGSizeMake(1.0,1.0);
messageText.layer.shadowRadius = 3.0;
[messageText setBackgroundColor:[UIColor clearColor]];
if(self.messageLabel.text && self.messageLabel.text.length>0) {
[messageText setText:self.messageLabel.text];
} else {
[messageText setText:@"no message"];
}
[messageText setTextAlignment:NSTextAlignmentCenter];
[messageText setEditable:NO];
[messageText addObserver:self forKeyPath:@"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];
self.bigMessageText = messageText;
[vibrancyEffectView.contentView addSubview:messageText];
self.blurView = blurEffectView;
UITapGestureRecognizer *dismiss = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeBlurView)];
[self.blurView addGestureRecognizer:dismiss];
[self.viewController.view addSubview:self.blurView];
[self.class centerContentForTextView:messageText];
[self.blurView setAlpha:0.0];
[UIView animateWithDuration:0.2 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:0.5 options:UIViewAnimationOptionCurveEaseIn animations:^{
[self.blurView setAlpha:1.0];
} completion:nil
}];
Although the documentation suggests you use the same UIVisualEffect
as the UIVisualEffectView
:
When you create a new vibrancy effect, use the same UIBlurEffect that you used to create the blur view. Using a different UIBlurEffect can cause unwanted visual effect combinations.
I would recommend setting your UIVibrancyEffect
to UIBlurEffectStyleLight
:
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[blurEffectView setFrame:self.viewController.view.bounds];
UIBlurEffect *vibrancyBlurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:vibrancyBlurEffect];
UIVisualEffectView *vibrancyEffectView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
[vibrancyEffectView setFrame:self.viewController.view.bounds];
[blurEffectView.contentView addSubview:vibrancyEffectView];
Add Exactly same Label/TextView to vibrancyEffectView
(not contentView)
The Label/TextView should have a alpha
less than 1.0. I kept it 0.5. You Can Try any other Value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With