Mobility UIVibrancyEffect UIVisualEffectView is not dynamic enough

We have successfully integrated UIVibranceEffect and UIVisualEffectView into our application, but I notice that the vibration is not as intense as I would like, and the text is dimmer than the demos I saw. I cannot find a way to change this or influence it in any way. I thought it might be because we use our own font, but I tried it too, and the font is thicker but still looks dull. Any ideas?

With our custom Open Sans Light font:

screenshot of our custom font (open sans light)

With system font:

screenshot 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 }]; 
+6
source share
2 answers

Although the documentation is used , you are using the same UIVisualEffect as UIVisualEffectView :

When you create a new shortcut effect, use the same UIBlurEffect that you used to create the blur. Using a different UIBlurEffect may cause unwanted combinations of visual effects.

I would recommend setting 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]; 
+2
source

Add exactly the same shortcut / TextView to vibrancyEffectView (not contentView)

Label / TextView should have alpha less than 1.0. I saved it 0.5. You can try any other value.

0
source

Source: https://habr.com/ru/post/975330/


All Articles