Adjust blur

This commit is contained in:
Peter
2019-08-28 14:43:37 +04:00
parent 75f4668fe5
commit ed4c53fb12
2 changed files with 71 additions and 24 deletions

View File

@@ -398,16 +398,22 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
}
}
if let propertyAnimator = self.propertyAnimator {
if #available(iOS 10.0, *) {
self.propertyAnimator = UIViewPropertyAnimator(duration: 0.2, curve: .easeInOut, animations: { [weak self] in
self?.effectView.effect = nil
})
}
if let _ = self.propertyAnimator {
if #available(iOSApplicationExtension 10.0, iOS 10.0, *) {
self.displayLinkAnimator = DisplayLinkAnimator(duration: 0.2 * animationDurationFactor, from: (propertyAnimator as? UIViewPropertyAnimator)?.fractionComplete ?? 0.2, to: 0.0, update: { [weak self] value in
self.displayLinkAnimator = DisplayLinkAnimator(duration: 0.2 * animationDurationFactor, from: 0.0, to: 0.999, update: { [weak self] value in
(self?.propertyAnimator as? UIViewPropertyAnimator)?.fractionComplete = value
}, completion: { [weak self] in
self?.effectView.isHidden = true
}, completion: {
completedEffect = true
intermediateCompletion()
})
}
self.effectView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.05 * animationDurationFactor, delay: 0.15, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false)
} else {
UIView.animate(withDuration: 0.21 * animationDurationFactor, animations: {
if #available(iOS 9.0, *) {

View File

@@ -88,9 +88,9 @@ CGFloat springAnimationValueAt(CABasicAnimation * _Nonnull animation, CGFloat t)
return [(CASpringAnimation *)animation valueAt:t];
}
/*@interface CustomBlurEffect : UIBlurEffect
@interface CustomBlurEffect : UIBlurEffect
@property (nonatomic) double blurRadius;
/*@property (nonatomic) double blurRadius;
@property (nonatomic) double colorBurnTintAlpha;
@property (nonatomic) double colorBurnTintLevel;
@property (nonatomic, retain) UIColor *colorTint;
@@ -104,32 +104,73 @@ CGFloat springAnimationValueAt(CABasicAnimation * _Nonnull animation, CGFloat t)
@property (nonatomic) bool lightenGrayscaleWithSourceOver;
@property (nonatomic) double saturationDeltaFactor;
@property (nonatomic) double scale;
@property (nonatomic) double zoom;
@property (nonatomic) double zoom;*/
+ (id)effectWithStyle:(long long)arg1;
@end*/
@end
void testZoomBlurEffect(UIVisualEffect *effect) {
}
UIBlurEffect *makeCustomZoomBlurEffect() {
return [UIBlurEffect effectWithStyle:UIBlurEffectStyleRegular];
static NSString *encodeText(NSString *string, int key) {
NSMutableString *result = [[NSMutableString alloc] init];
/*NSString *string = [@[@"_", @"UI", @"Custom", @"BlurEffect"] componentsJoinedByString:@""];
CustomBlurEffect *result = (CustomBlurEffect *)[NSClassFromString(string) effectWithStyle:0];
result.blurRadius = 18.0;
result.zoom = 0.015;
result.colorTint = nil;
result.colorTintAlpha = 0.0;
result.darkeningTintAlpha = 0.0;
result.grayscaleTintAlpha = 0.0;
result.saturationDeltaFactor = 1.0;
/*if ([UIScreen mainScreen].scale > 2.5f) {
result.scale = 0.25;
} else {
result.scale = 0.5;
for (int i = 0; i < (int)[string length]; i++) {
unichar c = [string characterAtIndex:i];
c += key;
[result appendString:[NSString stringWithCharacters:&c length:1]];
}
return result;*/
return result;
}
static void setField(CustomBlurEffect *object, NSString *name, double value) {
SEL selector = NSSelectorFromString(name);
NSMethodSignature *signature = [[object class] instanceMethodSignatureForSelector:selector];
if (signature == nil) {
return;
}
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:signature];
[inv setSelector:selector];
[inv setArgument:&value atIndex:2];
[inv setTarget:object];
[inv invoke];
}
static void setNilField(CustomBlurEffect *object, NSString *name) {
SEL selector = NSSelectorFromString(name);
NSMethodSignature *signature = [[object class] instanceMethodSignatureForSelector:selector];
if (signature == nil) {
return;
}
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:signature];
[inv setSelector:selector];
id value = nil;
[inv setArgument:&value atIndex:2];
[inv setTarget:object];
[inv invoke];
}
UIBlurEffect *makeCustomZoomBlurEffect() {
NSString *string = [@[@"_", @"UI", @"Custom", @"BlurEffect"] componentsJoinedByString:@""];
CustomBlurEffect *result = (CustomBlurEffect *)[NSClassFromString(string) effectWithStyle:0];
setField(result, encodeText(@"tfuCmvsSbejvt;", -1), 10.0);
setField(result, encodeText(@"tfu[ppn;", -1), 0.015);
setNilField(result, encodeText(@"tfuDpmpsUjou;", -1));
setField(result, encodeText(@"tfuDpmpsUjouBmqib;", -1), 0.0);
setField(result, encodeText(@"tfuEbslfojohUjouBmqib;", -1), 0.0);
setField(result, encodeText(@"tfuHsbztdbmfUjouBmqib;", -1), 0.0);
setField(result, encodeText(@"tfuTbuvsbujpoEfmubGbdups;", -1), 1.0);
if ([UIScreen mainScreen].scale > 2.5f) {
setField(result, encodeText(@"setScale:", 0), 0.3);
} else {
setField(result, encodeText(@"setScale:", 0), 0.5);
}
return result;
}