0

I'd like to use react-native-blur on my iOS app with React Native, using an alternative visualization on iOS 7 (such as a backgroundColor), which does not support UIVisualEffectView.

E.g.:

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

How can I detect if UIVisualEffectView is supported by the current platform?

gpbl
  • 4,721
  • 5
  • 31
  • 45

2 Answers2

1

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")
}
Asaf
  • 2,158
  • 2
  • 25
  • 40
  • Hi, thanks for the answer, my question was for react-native. I've updated the title to make it clearer. – gpbl Jun 08 '15 at 09:48
0

Just write a native module which export iOS version to JS, then JS detect the version and decide if UIVisualEffectView is supported.

Yinfeng
  • 5,131
  • 1
  • 18
  • 15