diff --git a/README.md b/README.md
index 6f60d76..d43dbe0 100644
--- a/README.md
+++ b/README.md
@@ -168,8 +168,6 @@ const Menu = React.createClass({
- `blurAmount` (Default: 10, Number) - blur amount effect
- `0-100` - Adjusts blur intensity
-*Note: `blurAmount` does not refresh with Hot Reloading. You must a refresh the app to view the results of the changes*
-
### Android
Android support uses an [external library](https://github.com/500px/500px-android-blur) which has slightly different properties and setup requirements. This is why extra code must be added manually to the `android/app/build.gradle` file as documented above.
diff --git a/examples/Basic/index.ios.js b/examples/Basic/index.ios.js
index 79db83e..1960a84 100644
--- a/examples/Basic/index.ios.js
+++ b/examples/Basic/index.ios.js
@@ -16,9 +16,9 @@ import {
import { BlurView, VibrancyView } from 'react-native-blur'
class Basic extends Component {
+ constructor(props) {
+ super(props)
- constructor() {
- super()
this.state = {
showBlurs: true,
blurBlurType: 'light',
@@ -60,14 +60,15 @@ class Basic extends Component {
blurAmount={10}
style={[styles.blurView]} />
- {`Blur component`}
+ Blur component
{this._onBlurChange(event)}}
onValueChange={(value) => {this._onBlurValueChange(value)}}
- tintColor={this.state.blurBlurType == 'xlight' ? 'black' : 'white'}/>
+ tintColor={this.state.blurBlurType === 'xlight' ? 'black' : 'white'}
+ />
{/*
@@ -76,15 +77,16 @@ class Basic extends Component {
*/}
- {`Vibrancy component`}
+ Vibrancy component
{this._onVibrancyChange(event)}}
onValueChange={(value) => {this._onVibrancyValueChange(value)}}
- tintColor={this.state.vibrancyBlurType == 'xlight' ? 'black' : 'white'}/>
+ tintColor="white"
+ />
)
diff --git a/examples/Basic/ios/Basic.xcodeproj/project.pbxproj b/examples/Basic/ios/Basic.xcodeproj/project.pbxproj
index 9b700dc..1d11d09 100644
--- a/examples/Basic/ios/Basic.xcodeproj/project.pbxproj
+++ b/examples/Basic/ios/Basic.xcodeproj/project.pbxproj
@@ -5,6 +5,7 @@
};
objectVersion = 46;
objects = {
+
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -102,6 +103,13 @@
remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;
remoteInfo = React;
};
+ 209F89F11EA224BB004ABC64 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 482A4E939D364AA89A71D498 /* RNBlur.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = A68BD7BC1BC31318005F02DF;
+ remoteInfo = RNBlur;
+ };
2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
@@ -252,11 +260,11 @@
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; };
2D02E47B1E0B4A5D006451C7 /* Basic-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Basic-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D02E4901E0B4A5D006451C7 /* Basic-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Basic-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 482A4E939D364AA89A71D498 /* RNBlur.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNBlur.xcodeproj; path = ../../../ios/RNBlur.xcodeproj; sourceTree = ""; };
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; };
- 482A4E939D364AA89A71D498 /* RNBlur.xcodeproj */ = {isa = PBXFileReference; name = "RNBlur.xcodeproj"; path = "../node_modules/react-native-blur/ios/RNBlur.xcodeproj"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
- A8E69D2A0C5C4828B32057AD /* libRNBlur.a */ = {isa = PBXFileReference; name = "libRNBlur.a"; path = "libRNBlur.a"; sourceTree = ""; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
+ A8E69D2A0C5C4828B32057AD /* libRNBlur.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNBlur.a; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -418,6 +426,14 @@
name = Products;
sourceTree = "";
};
+ 209F89D51EA224BB004ABC64 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 209F89F21EA224BB004ABC64 /* libRNBlur.a */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
5E91572E1DD0AC6500FF2AA8 /* Products */ = {
isa = PBXGroup;
children = (
@@ -568,7 +584,7 @@
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 610;
+ LastUpgradeCheck = 0830;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
00E356ED1AD99517003FC87E = {
@@ -642,6 +658,10 @@
ProductGroup = 146834001AC3E56700842450 /* Products */;
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
+ {
+ ProductGroup = 209F89D51EA224BB004ABC64 /* Products */;
+ ProjectRef = 482A4E939D364AA89A71D498 /* RNBlur.xcodeproj */;
+ },
);
projectRoot = "";
targets = (
@@ -710,6 +730,13 @@
remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
+ 209F89F21EA224BB004ABC64 /* libRNBlur.a */ = {
+ isa = PBXReferenceProxy;
+ fileType = archive.ar;
+ path = libRNBlur.a;
+ remoteRef = 209F89F11EA224BB004ABC64 /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
@@ -967,23 +994,24 @@
"DEBUG=1",
"$(inherited)",
);
- INFOPLIST_FILE = BasicTests/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
- OTHER_LDFLAGS = (
- "-ObjC",
- "-lc++",
- );
- PRODUCT_NAME = "$(TARGET_NAME)";
- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic.app/Basic";
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "\"$(SRCROOT)/$(TARGET_NAME)\"",
- );
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-blur/ios",
);
+ INFOPLIST_FILE = BasicTests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/$(TARGET_NAME)\"",
+ );
+ OTHER_LDFLAGS = (
+ "-ObjC",
+ "-lc++",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic.app/Basic";
};
name = Debug;
};
@@ -992,23 +1020,24 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
- INFOPLIST_FILE = BasicTests/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
- LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
- OTHER_LDFLAGS = (
- "-ObjC",
- "-lc++",
- );
- PRODUCT_NAME = "$(TARGET_NAME)";
- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic.app/Basic";
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "\"$(SRCROOT)/$(TARGET_NAME)\"",
- );
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(SRCROOT)/../node_modules/react-native-blur/ios",
);
+ INFOPLIST_FILE = BasicTests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/$(TARGET_NAME)\"",
+ );
+ OTHER_LDFLAGS = (
+ "-ObjC",
+ "-lc++",
+ );
+ PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic.app/Basic";
};
name = Release;
};
@@ -1018,6 +1047,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(SRCROOT)/../node_modules/react-native-blur/ios",
+ );
INFOPLIST_FILE = Basic/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
@@ -1025,12 +1058,9 @@
"-ObjC",
"-lc++",
);
+ PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Basic;
VERSIONING_SYSTEM = "apple-generic";
- HEADER_SEARCH_PATHS = (
- "$(inherited)",
- "$(SRCROOT)/../node_modules/react-native-blur/ios",
- );
};
name = Debug;
};
@@ -1039,6 +1069,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(SRCROOT)/../node_modules/react-native-blur/ios",
+ );
INFOPLIST_FILE = Basic/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
@@ -1046,12 +1080,9 @@
"-ObjC",
"-lc++",
);
+ PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = Basic;
VERSIONING_SYSTEM = "apple-generic";
- HEADER_SEARCH_PATHS = (
- "$(inherited)",
- "$(SRCROOT)/../node_modules/react-native-blur/ios",
- );
};
name = Release;
};
@@ -1067,8 +1098,16 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_TESTABILITY = YES;
GCC_NO_COMMON_BLOCKS = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(SRCROOT)/../node_modules/react-native-blur/ios",
+ );
INFOPLIST_FILE = "Basic-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/$(TARGET_NAME)\"",
+ );
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
@@ -1078,14 +1117,6 @@
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.2;
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "\"$(SRCROOT)/$(TARGET_NAME)\"",
- );
- HEADER_SEARCH_PATHS = (
- "$(inherited)",
- "$(SRCROOT)/../node_modules/react-native-blur/ios",
- );
};
name = Debug;
};
@@ -1101,8 +1132,16 @@
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_NO_COMMON_BLOCKS = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(SRCROOT)/../node_modules/react-native-blur/ios",
+ );
INFOPLIST_FILE = "Basic-tvOS/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/$(TARGET_NAME)\"",
+ );
OTHER_LDFLAGS = (
"-ObjC",
"-lc++",
@@ -1112,14 +1151,6 @@
SDKROOT = appletvos;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.2;
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "\"$(SRCROOT)/$(TARGET_NAME)\"",
- );
- HEADER_SEARCH_PATHS = (
- "$(inherited)",
- "$(SRCROOT)/../node_modules/react-native-blur/ios",
- );
};
name = Release;
};
@@ -1136,15 +1167,15 @@
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "Basic-tvOSTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/$(TARGET_NAME)\"",
+ );
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.Basic-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic-tvOS.app/Basic-tvOS";
TVOS_DEPLOYMENT_TARGET = 10.1;
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "\"$(SRCROOT)/$(TARGET_NAME)\"",
- );
};
name = Debug;
};
@@ -1161,15 +1192,15 @@
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "Basic-tvOSTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)/$(TARGET_NAME)\"",
+ );
PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.Basic-tvOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Basic-tvOS.app/Basic-tvOS";
TVOS_DEPLOYMENT_TARGET = 10.1;
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "\"$(SRCROOT)/$(TARGET_NAME)\"",
- );
};
name = Release;
};
@@ -1186,15 +1217,19 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
@@ -1227,8 +1262,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -1236,6 +1273,7 @@
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
diff --git a/examples/Basic/ios/Basic.xcodeproj/xcshareddata/xcschemes/Basic-tvOS.xcscheme b/examples/Basic/ios/Basic.xcodeproj/xcshareddata/xcschemes/Basic-tvOS.xcscheme
index c3bc087..345e519 100644
--- a/examples/Basic/ios/Basic.xcodeproj/xcshareddata/xcschemes/Basic-tvOS.xcscheme
+++ b/examples/Basic/ios/Basic.xcodeproj/xcshareddata/xcschemes/Basic-tvOS.xcscheme
@@ -1,6 +1,6 @@
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
- org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
+ $(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
@@ -24,6 +24,19 @@
1
LSRequiresIPhoneOS
+ NSAppTransportSecurity
+
+ NSExceptionDomains
+
+ localhost
+
+ NSExceptionAllowsInsecureHTTPLoads
+
+
+
+
+ NSLocationWhenInUseUsageDescription
+
UILaunchStoryboardName
LaunchScreen
UIRequiredDeviceCapabilities
@@ -38,19 +51,5 @@
UIViewControllerBasedStatusBarAppearance
- NSLocationWhenInUseUsageDescription
-
- NSAppTransportSecurity
-
-
- NSExceptionDomains
-
- localhost
-
- NSExceptionAllowsInsecureHTTPLoads
-
-
-
-
diff --git a/examples/Basic/ios/BasicTests/Info.plist b/examples/Basic/ios/BasicTests/Info.plist
index 886825c..ba72822 100644
--- a/examples/Basic/ios/BasicTests/Info.plist
+++ b/examples/Basic/ios/BasicTests/Info.plist
@@ -7,7 +7,7 @@
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
- org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
+ $(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
diff --git a/ios/BlurAmount.h b/ios/BlurAmount.h
deleted file mode 100644
index 42aa33a..0000000
--- a/ios/BlurAmount.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#import
-
-@interface BlurAmount : UIBlurEffect
-
-@property (nonatomic, copy) NSNumber *blurAmount;
-
-+ (id)updateBlurAmount:(NSNumber*)blurAmount;
-
-@end
diff --git a/ios/BlurAmount.m b/ios/BlurAmount.m
deleted file mode 100644
index 1d84977..0000000
--- a/ios/BlurAmount.m
+++ /dev/null
@@ -1,54 +0,0 @@
-#import "BlurAmount.h"
-#import
-
-@interface UIBlurEffect (Protected)
-
-@property (nonatomic, readonly) id effectSettings;
-@property (nonatomic, copy, class) NSNumber *localBlurAmount;
-
-@end
-
-
-@implementation BlurAmount
-
-static NSNumber *_localBlurAmount = nil;
-
-+ (instancetype)effectWithStyle:(UIBlurEffectStyle)style
-{
- id result = [super effectWithStyle:style];
- object_setClass(result, self);
-
- return result;
-}
-
-- (id)effectSettings
-{
- id settings = [super effectSettings];
- [settings setValue:BlurAmount.localBlurAmount forKey:@"blurRadius"];
- return settings;
-}
-
-- (id)copyWithZone:(NSZone*)zone
-{
- id result = [super copyWithZone:zone];
- object_setClass(result, [self class]);
- return result;
-}
-
-+ (void)setLocalBlurAmount:(NSNumber *)localBlurAmount {
- if (localBlurAmount != _localBlurAmount) {
- _localBlurAmount = localBlurAmount;
- }
-}
-
-+ (NSNumber *)localBlurAmount {
- return _localBlurAmount;
-}
-
-+ (id)updateBlurAmount:(NSNumber*)blurAmount
-{
- self.localBlurAmount = blurAmount;
- return blurAmount;
-}
-
-@end
diff --git a/ios/BlurEffectWithAmount.h b/ios/BlurEffectWithAmount.h
new file mode 100644
index 0000000..bf3992a
--- /dev/null
+++ b/ios/BlurEffectWithAmount.h
@@ -0,0 +1,7 @@
+#import
+
+@interface BlurEffectWithAmount : UIBlurEffect
+@property (nonatomic, strong) NSNumber *blurAmount;
+
++ (instancetype)effectWithStyle:(UIBlurEffectStyle)style andBlurAmount:(NSNumber*)blurAmount;
+@end
diff --git a/ios/BlurEffectWithAmount.m b/ios/BlurEffectWithAmount.m
new file mode 100644
index 0000000..e279400
--- /dev/null
+++ b/ios/BlurEffectWithAmount.m
@@ -0,0 +1,65 @@
+//
+// We subclass UIBlurEffect so that we can set the BlurAmount.
+// See: http://stackoverflow.com/a/30744777/304706
+//
+
+#import "BlurEffectWithAmount.h"
+#import
+
+@interface UIBlurEffect (Protected)
+
+@property (nonatomic, readonly) id effectSettings;
+
+@end
+
+@implementation BlurEffectWithAmount
+@dynamic blurAmount;
+
++ (instancetype)effectWithStyle:(UIBlurEffectStyle)style
+{
+ id instance = [super effectWithStyle:style];
+ object_setClass(instance, self);
+ return instance;
+}
+
++ (instancetype)effectWithStyle:(UIBlurEffectStyle)style andBlurAmount:(NSNumber*)blurAmount
+{
+ BlurEffectWithAmount *effect = (BlurEffectWithAmount*)[self effectWithStyle:style];
+ effect.blurAmount = blurAmount;
+ return effect;
+}
+
+- (void)setBlurAmount:(NSNumber*)blurAmount {
+ objc_setAssociatedObject(self,
+ @selector(blurAmount),
+ blurAmount,
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+- (NSNumber*)blurAmount {
+ return objc_getAssociatedObject(self, @selector(blurAmount));
+}
+
+- (id)effectSettings
+{
+ id settings = [super effectSettings];
+ NSNumber *blurAmount = self.blurAmount;
+ if (blurAmount) {
+ [settings setValue:blurAmount forKey:@"blurRadius"];
+ }
+ return settings;
+}
+
+- (id)copyWithZone:(NSZone*)zone
+{
+ id instance = [super copyWithZone:zone];
+ object_setClass(instance, [self class]);
+ // Must also copy blur amount to new instance
+ objc_setAssociatedObject(instance,
+ @selector(blurAmount),
+ self.blurAmount,
+ OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+ return instance;
+}
+
+@end
diff --git a/ios/BlurView.h b/ios/BlurView.h
index b0ac206..93d693a 100644
--- a/ios/BlurView.h
+++ b/ios/BlurView.h
@@ -1,8 +1,13 @@
#import
+#import "BlurEffectWithAmount.h"
@interface BlurView : UIView
@property (nonatomic, copy) NSString *blurType;
@property (nonatomic, copy) NSNumber *blurAmount;
+@property (nonatomic, strong) BlurEffectWithAmount *blurEffect;
+@property (nonatomic, strong) UIVisualEffectView *blurEffectView;
+
+- (void)updateBlurEffect;
@end
diff --git a/ios/BlurView.m b/ios/BlurView.m
index e546ce3..4a7a871 100644
--- a/ios/BlurView.m
+++ b/ios/BlurView.m
@@ -1,48 +1,66 @@
-#import
#import "BlurView.h"
-#import "BlurAmount.h"
+#import "BlurEffectWithAmount.h"
@interface BlurView ()
-@property (nonatomic, strong) UIVisualEffectView *visualEffectView;
-@property (nonatomic, strong) UIBlurEffect *blurEffect;
-
@end
@implementation BlurView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
- self.blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- self.visualEffectView = [[UIVisualEffectView alloc] initWithEffect:self.blurEffect];
- self.visualEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- self.visualEffectView.frame = frame;
+ self.blurEffectView = [[UIVisualEffectView alloc] init];
+ self.blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ self.blurEffectView.frame = frame;
+
+ self.blurAmount = @10;
+ self.blurType = @"dark";
+ [self updateBlurEffect];
self.clipsToBounds = true;
- [self addSubview:self.visualEffectView];
+ [self addSubview:self.blurEffectView];
}
return self;
}
+- (void)layoutSubviews
+{
+ [super layoutSubviews];
+ self.blurEffectView.frame = self.bounds;
+}
+
- (void)setBlurType:(NSString *)blurType
{
- if ([blurType isEqual: @"xlight"]) {
- self.blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
- } else if ([blurType isEqual: @"light"]) {
- self.blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
- } else if ([blurType isEqual: @"dark"]) {
- self.blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- } else {
- self.blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- }
- self.visualEffectView.effect = self.blurEffect;
+ if (blurType && ![self.blurType isEqual:blurType]) {
+ _blurType = blurType;
+ [self updateBlurEffect];
+ }
}
- (void)setBlurAmount:(NSNumber *)blurAmount
{
- [BlurAmount updateBlurAmount:blurAmount];
+ if (blurAmount && ![self.blurAmount isEqualToNumber:blurAmount]) {
+ _blurAmount = blurAmount;
+ [self updateBlurEffect];
+ }
+}
+
+
+- (UIBlurEffectStyle)blurEffectStyle
+{
+ if ([self.blurType isEqual: @"xlight"]) return UIBlurEffectStyleExtraLight;
+ if ([self.blurType isEqual: @"light"]) return UIBlurEffectStyleLight;
+ if ([self.blurType isEqual: @"dark"]) return UIBlurEffectStyleDark;
+ return UIBlurEffectStyleDark;
+}
+
+- (void)updateBlurEffect
+{
+ UIBlurEffectStyle style = [self blurEffectStyle];
+ self.blurEffect = [BlurEffectWithAmount effectWithStyle:style andBlurAmount:self.blurAmount];
+ self.blurEffectView.effect = self.blurEffect;
}
@end
diff --git a/ios/RNBlur.xcodeproj/project.pbxproj b/ios/RNBlur.xcodeproj/project.pbxproj
index a1ac5dd..4e695c1 100644
--- a/ios/RNBlur.xcodeproj/project.pbxproj
+++ b/ios/RNBlur.xcodeproj/project.pbxproj
@@ -7,9 +7,9 @@
objects = {
/* Begin PBXBuildFile section */
+ 256D23D71E1EBA540023CA16 /* BlurEffectWithAmount.m in Sources */ = {isa = PBXBuildFile; fileRef = 256D23D61E1EBA540023CA16 /* BlurEffectWithAmount.m */; };
A68BD7CC1BC31332005F02DF /* VibrancyView.m in Sources */ = {isa = PBXBuildFile; fileRef = A68BD7C91BC31332005F02DF /* VibrancyView.m */; };
A68BD7CD1BC31332005F02DF /* VibrancyViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A68BD7CB1BC31332005F02DF /* VibrancyViewManager.m */; };
- 256D23D71E1EBA540023CA16 /* BlurAmount.m in Sources */ = {isa = PBXBuildFile; fileRef = 256D23D61E1EBA540023CA16 /* BlurAmount.m */; };
A68BD7D21BC31341005F02DF /* BlurView.m in Sources */ = {isa = PBXBuildFile; fileRef = A68BD7CF1BC31341005F02DF /* BlurView.m */; };
A68BD7D31BC31341005F02DF /* BlurViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A68BD7D11BC31341005F02DF /* BlurViewManager.m */; };
/* End PBXBuildFile section */
@@ -27,13 +27,13 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 256D23D51E1EBA540023CA16 /* BlurEffectWithAmount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlurEffectWithAmount.h; sourceTree = ""; };
+ 256D23D61E1EBA540023CA16 /* BlurEffectWithAmount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BlurEffectWithAmount.m; sourceTree = ""; };
A68BD7BC1BC31318005F02DF /* libRNBlur.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNBlur.a; sourceTree = BUILT_PRODUCTS_DIR; };
A68BD7C81BC31332005F02DF /* VibrancyView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VibrancyView.h; sourceTree = SOURCE_ROOT; };
A68BD7C91BC31332005F02DF /* VibrancyView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VibrancyView.m; sourceTree = SOURCE_ROOT; };
A68BD7CA1BC31332005F02DF /* VibrancyViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VibrancyViewManager.h; sourceTree = SOURCE_ROOT; };
A68BD7CB1BC31332005F02DF /* VibrancyViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VibrancyViewManager.m; sourceTree = SOURCE_ROOT; };
- 256D23D51E1EBA540023CA16 /* BlurAmount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlurAmount.h; sourceTree = ""; };
- 256D23D61E1EBA540023CA16 /* BlurAmount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BlurAmount.m; sourceTree = ""; };
A68BD7CE1BC31341005F02DF /* BlurView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlurView.h; sourceTree = SOURCE_ROOT; };
A68BD7CF1BC31341005F02DF /* BlurView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BlurView.m; sourceTree = SOURCE_ROOT; };
A68BD7D01BC31341005F02DF /* BlurViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlurViewManager.h; sourceTree = SOURCE_ROOT; };
@@ -54,8 +54,8 @@
A68BD7B31BC31318005F02DF = {
isa = PBXGroup;
children = (
- 256D23D51E1EBA540023CA16 /* BlurAmount.h */,
- 256D23D61E1EBA540023CA16 /* BlurAmount.m */,
+ 256D23D51E1EBA540023CA16 /* BlurEffectWithAmount.h */,
+ 256D23D61E1EBA540023CA16 /* BlurEffectWithAmount.m */,
A68BD7CE1BC31341005F02DF /* BlurView.h */,
A68BD7CF1BC31341005F02DF /* BlurView.m */,
A68BD7D01BC31341005F02DF /* BlurViewManager.h */,
@@ -134,7 +134,7 @@
files = (
A68BD7CC1BC31332005F02DF /* VibrancyView.m in Sources */,
A68BD7CD1BC31332005F02DF /* VibrancyViewManager.m in Sources */,
- 256D23D71E1EBA540023CA16 /* BlurAmount.m in Sources */,
+ 256D23D71E1EBA540023CA16 /* BlurEffectWithAmount.m in Sources */,
A68BD7D21BC31341005F02DF /* BlurView.m in Sources */,
A68BD7D31BC31341005F02DF /* BlurViewManager.m in Sources */,
);
diff --git a/ios/VibrancyView.h b/ios/VibrancyView.h
index 003d723..a5c0608 100644
--- a/ios/VibrancyView.h
+++ b/ios/VibrancyView.h
@@ -1,7 +1,4 @@
-#import
+#import "BlurView.h"
-@interface VibrancyView : UIView
-
-@property (nonatomic, copy) NSString *blurType;
-
-@end
\ No newline at end of file
+@interface VibrancyView : BlurView
+@end
diff --git a/ios/VibrancyView.m b/ios/VibrancyView.m
index 450a4a2..4cbca84 100644
--- a/ios/VibrancyView.m
+++ b/ios/VibrancyView.m
@@ -1,12 +1,11 @@
-#import
-#import "VibrancyView.h"
-#import "BlurView.h"
#import
+#import "BlurView.h"
+#import "VibrancyView.h"
@interface VibrancyView ()
-@property (nonatomic, strong) UIVisualEffectView *visualEffectView;
-@property (nonatomic, strong) UIVisualEffectView *vibrancyView;
+@property (nonatomic, strong) UIVibrancyEffect *vibrancyEffect;
+@property (nonatomic, strong) UIVisualEffectView *vibrancyEffectView;
@end
@@ -14,48 +13,36 @@
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
- UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- self.visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
+ self.vibrancyEffectView = [[UIVisualEffectView alloc] init];
+ self.vibrancyEffectView.frame = frame;
+ [self updateVibrancyEffect];
- UIVibrancyEffect *vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
- self.vibrancyView = [[UIVisualEffectView alloc] initWithEffect:vibrancyEffect];
-
- self.visualEffectView.frame = frame;
- self.vibrancyView.frame = frame;
-
- [self addSubview:self.visualEffectView];
- [self.visualEffectView.contentView addSubview:self.vibrancyView];
+ [self.blurEffectView.contentView addSubview:self.vibrancyEffectView];
}
return self;
}
--(void)layoutSubviews
+- (void)layoutSubviews
{
[super layoutSubviews];
-
- self.visualEffectView.frame = self.bounds;
- self.vibrancyView.frame = self.bounds;
-}
-
-- (void)setBlurType:(NSString *)blurType {
- UIBlurEffect *blurEffect;
-
- self.clipsToBounds = true;
- if ([blurType isEqual: @"xlight"]) {
- blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
- } else if ([blurType isEqual: @"light"]) {
- blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
- } else if ([blurType isEqual: @"dark"]) {
- blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- } else {
- blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
- }
- self.visualEffectView.effect = blurEffect;
+ self.vibrancyEffectView.frame = self.bounds;
}
- (void)insertReactSubview:(id)subview atIndex:(NSInteger)atIndex {
- [self.vibrancyView.contentView addSubview:(UIView*)subview];
+ [self.vibrancyEffectView.contentView addSubview:(UIView*)subview];
+}
+
+- (void)updateBlurEffect
+{
+ [super updateBlurEffect];
+ [self updateVibrancyEffect];
+}
+
+- (void)updateVibrancyEffect
+{
+ self.vibrancyEffect = [UIVibrancyEffect effectForBlurEffect:self.blurEffect];
+ self.vibrancyEffectView.effect = self.vibrancyEffect;
}
@end
diff --git a/ios/VibrancyViewManager.m b/ios/VibrancyViewManager.m
index d4e2176..f050490 100644
--- a/ios/VibrancyViewManager.m
+++ b/ios/VibrancyViewManager.m
@@ -1,5 +1,3 @@
-#import
-#import
#import "VibrancyViewManager.h"
#import "VibrancyView.h"
@@ -13,5 +11,6 @@ RCT_EXPORT_MODULE();
}
RCT_EXPORT_VIEW_PROPERTY(blurType, NSString);
+RCT_EXPORT_VIEW_PROPERTY(blurAmount, NSNumber);
@end
diff --git a/src/VibrancyView.ios.js b/src/VibrancyView.ios.js
index f7c9a8c..dd6fedc 100644
--- a/src/VibrancyView.ios.js
+++ b/src/VibrancyView.ios.js
@@ -8,7 +8,7 @@ class VibrancyView extends Component {
{...this.props}
style={[{
backgroundColor: 'transparent',
- }, this.props.style
+ }, this.props.style,
]}
/>
);
@@ -17,6 +17,11 @@ class VibrancyView extends Component {
VibrancyView.propTypes = {
blurType: PropTypes.string,
+ blurAmount: PropTypes.number.isRequired,
+};
+
+VibrancyView.defaultProps = {
+ blurAmount: 10,
};
const NativeVibrancyView = requireNativeComponent('VibrancyView', VibrancyView);