mirror of
https://github.com/status-im/react-native-blur.git
synced 2025-02-20 03:58:05 +00:00
This moves to modern Objective-C practices. Synthesized properties now use property declarations in a private category. UIVisualEffectViews will now only be created once, rather than on each change of blurType. BlurAmount uses a class property to track the currently set amount.
55 lines
1.1 KiB
Objective-C
55 lines
1.1 KiB
Objective-C
#import "BlurAmount.h"
|
|
#import <objc/runtime.h>
|
|
|
|
@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
|