ios - react native : detect if UIVisualEffectView is supported

标签 ios react-native uivisualeffectview

我想使用 react-native-blur在我的带有 React Native 的 iOS 应用程序上,在 iOS 7 上使用替代可视化(例如 backgroundColor),它不支持 UIVisualEffectView

例如:

styles = { 
    backgroundColor: isVisualEffectViewSupported ? "transparent" : "rgba(0,0,0,.5)"
}

如何检测当前平台是否支持 UIVisualEffectView?

最佳答案

objective-C :

Class cls = NSClassFromString(@"UIVisualEffectView");
if (cls) {
    // class exists, do whatever you need with it
} else {
    // class doesn't exists, fallback
}

swift :

if NSClassFromString("UIVisualEffectView") != nil {
    println("UIVisualEffectView exists")
} else {
    println("UIVisualEffectView does not exists")
}

关于ios - react native : detect if UIVisualEffectView is supported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30704400/

相关文章:

ios - 模糊 View 适用于模拟器,但不适用于设备

reactjs - 在 react-navigation 5.x 中放置 createSwitchNavigator 以从 react-navigation 4 迁移到 5.x

ios - Expo.Notifications.addListener() 未触发(iOS 独立应用程序)

ios - "UserNotificationsUI"在构建 UIKit for Mac 错误时不可用

ios - iOS 7.1 更新后 SpriteKit 游戏中的对象停止碰撞

android - 如何在 react-native 中滑动平面列表中的组件?

ios - 如何在 iOS 中将生动的文本向上移动?

ios - 带有 mask 层的 UIVisualEffectView

iPhone 4S - 它会有 UDID 吗?

ios - 无法使卡片翻转动画起作用