我们已经成功地将UIVibrancyEffect和UIVisualEffectView集成到我们的应用程序中,但我注意到它的活力并不像我想的那么强烈,文字比我见过的演示更暗淡。我找不到任何方法来调整它,或以任何方式影响它。我认为这可能是因为我们使用的是自定义字体,但我也尝试过,字体较粗但看起来仍然很暗淡。有什么想法吗?
使用我们的自定义字体Open Sans Light:
使用系统字体:
以下是代码:
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
}];
答案 0 :(得分:3)
虽然documentation suggests UIVisualEffect
与UIVisualEffectView
使用相同的UIVibrancyEffect
:
创建新的活力效果时,请使用相同的UIBlurEffect 你曾经用来创建模糊视图。使用不同的UIBlurEffect即可 引起不必要的视觉效果组合。
我建议您将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];
:
{{1}}
答案 1 :(得分:1)
将完全相同的Label / TextView添加到vibrancyEffectView
(不是contentView)
Label / TextView的alpha
应小于1.0。我保持0.5。你可以尝试任何其他价值。