gpt4 book ai didi

ios - UIVibrancyEffect UIVisualEffectView subview 不够生动

转载 作者:可可西里 更新时间:2023-11-01 03:32:19 29 4
gpt4 key购买 nike

我们已经成功地将 UIVibrancyEffect 和 UIVisualEffectView 集成到我们的应用程序中,但我注意到活力并没有我想要的那么强烈,而且文本比我看到的演示更暗淡。我找不到任何方法来调整它或以任何方式影响它。我想这可能是因为我们使用的是自定义字体,但我也试过了,字体变粗了,但看起来还是暗淡的。有什么想法吗?

使用我们的自定义字体 Open Sans Light:

screenshot of our custom font (open sans light)

使用系统字体:

screenshot with system font

代码如下:

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
}];

最佳答案

尽管 documentation suggests您使用与 UIVisualEffectView 相同的 UIVisualEffect:

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.

我建议将您的 UIVibrancyEffect 设置为 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];

关于ios - UIVibrancyEffect UIVisualEffectView subview 不够生动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25858402/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com