This commit is contained in:
Ali 2022-05-27 22:33:26 +04:00
parent f192fbf16b
commit e69e0a33dd
5 changed files with 51 additions and 2 deletions

View file

@ -48,3 +48,9 @@ void applyKeyboardAutocorrection(UITextView * _Nonnull textView);
@property (nonatomic, copy) UIInterfaceOrientationMask (^ _Nullable supportedOrientations)(void);
@end
@interface UIScrollView (FrameRateRangeOverride)
- (void)fixScrollDisplayLink;
@end

View file

@ -43,6 +43,7 @@ static const void *inputAccessoryHeightProviderKey = &inputAccessoryHeightProvid
static const void *interactiveTransitionGestureRecognizerTestKey = &interactiveTransitionGestureRecognizerTestKey;
static const void *UIViewControllerHintWillBePresentedInPreviewingContextKey = &UIViewControllerHintWillBePresentedInPreviewingContextKey;
static const void *disablesInteractiveModalDismissKey = &disablesInteractiveModalDismissKey;
static const void *forceFullRefreshRateKey = &forceFullRefreshRateKey;
static bool notyfyingShiftState = false;
@ -99,14 +100,41 @@ static bool notyfyingShiftState = false;
@implementation CADisplayLink (FrameRateRangeOverride)
- (void)_65087dc8_setPreferredFrameRateRange:(CAFrameRateRange)range API_AVAILABLE(ios(15.0)) {
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
range = CAFrameRateRangeMake(maxFps, maxFps, maxFps);
if ([self associatedObjectForKey:forceFullRefreshRateKey] != nil) {
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
range = CAFrameRateRangeMake(maxFps, maxFps, maxFps);
}
[self _65087dc8_setPreferredFrameRateRange:range];
}
@end
@implementation UIScrollView (FrameRateRangeOverride)
- (void)fixScrollDisplayLink {
static NSString *scrollHeartbeatKey = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
scrollHeartbeatKey = [NSString stringWithFormat:@"_%@", @"scrollHeartbeat"];
});
id value = [self valueForKey:scrollHeartbeatKey];
if ([value isKindOfClass:[CADisplayLink class]]) {
CADisplayLink *displayLink = (CADisplayLink *)value;
if ([displayLink associatedObjectForKey:forceFullRefreshRateKey] == nil) {
[displayLink setAssociatedObject:@true forKey:forceFullRefreshRateKey];
if (@available(iOS 15.0, *)) {
float maxFps = [UIScreen mainScreen].maximumFramesPerSecond;
[displayLink setPreferredFrameRateRange:CAFrameRateRangeMake(maxFps, maxFps, maxFps)];
}
}
}
}
@end
@implementation UIViewController (Navigation)
+ (void)load