gpt4 book ai didi

ios - 如何得到类似苹果 map 状态栏的模糊效果?

转载 作者:行者123 更新时间:2023-11-28 07:41:33 25 4
gpt4 key购买 nike

我正在开发一个基于 iOS 11 map 的应用程序,并希望将状态栏模糊化,就像它在 Apple map 中显示的那样。

这是它在 map 应用程序中的样子: enter image description here

目前,我正在使用 UIVisualEffectView 复制这种效果。这是我的代码:

let blurEffect = UIBlurEffect(style: .regular)
blurredStatusBar = UIVisualEffectView(effect: blurEffect)
blurredStatusBar?.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(blurredStatusBar!)

但是,无论我使用什么 UIBlurEffect,我都无法像 map 应用那样复制效果。以下是它寻找不同效果的方式:

.regular enter image description here

.prominent enter image description here

.light enter image description here

.extraLight enter image description here

我只想模糊状态栏,不添加任何饱和度、鲜艳度或任何白色色调。

有一个实例属性 - backgroundFilters ,这可能对我有帮助,但不幸的是它不适用于 iOS 上的图层。

建议了一种可能的解决方案 here是捕获图像中的 UIView 内容,然后模糊并显示它。但是,这对我来说不是一个可行的解决方案,因为我在状态栏下方有一张可以平移的 map 。在平移 map 时连续捕获下方 map 作为图像并对其进行模糊处理是没有意义的。

我尝试使用 ILTranslucentView ,它是 UIView 的一个小子类,提供原生 iOS 7+ 模糊(半透明)效果。它是这样出现的:

enter image description here

我尝试了几种不同的方法,例如 this , 但没有用。

最佳答案

我找到了上述问题的解决方案。我用了VisualEffectView达到效果。它允许您自定义 VisualEffectView 的颜色色调、模糊半径、模糊比例等属性。但是,应谨慎使用。它利用一个私有(private)的 UIKit API 来发挥它的魔力;将此代码提交到 App Store 会增加被拒绝的风险!

关于ios - 如何得到类似苹果 map 状态栏的模糊效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52112621/

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