iOS越狱插件Daisy的playHelloStartAnimation亮屏触发异常问题求解
iOS Tweak Daisy 动画异常修复求助
大家好,过去几天我一直在修改iOS tweak Daisy。目前我已成功新增多款字体、延长Hello动画屏幕停留时长,还合并了原开发者未接受的一个已关闭PR。现在我正在修复原版存在的bug:唤醒手机时playHelloStartAnimation偶现异常,有时会从头重播动画或从中间某几帧开始播放;有时播放完成后会出现数毫秒空白再跳转下一个动画,也有时可正常播放。我尝试过先播放空白动画遮挡异常、调整动画时长、更换其他hook点位,问题仍然复现,暂时无法定位原因,恳请各位提供帮助。
%group DiaryHello %hook CSCoverSheetView %property(nonatomic, retain)UIView* diaryHelloIconView; %property(nonatomic, retain)UILabel* diaryHelloLabel; - (void)didMoveToWindow { // add iphone hello %orig; // hello label if (enableHelloSwitch && showHelloGreetingSwitch && ![self diaryHelloLabel]) { self.diaryHelloLabel = [UILabel new]; [[self diaryHelloLabel] setTextColor:[UIColor whiteColor]]; if ([fontFamilyValue intValue] == 0) [[self diaryHelloLabel] setFont:[UIFont fontWithName:@"Selawik-Regular" size:24]]; else if ([fontFamilyValue intValue] == 1) [[self diaryHelloLabel] setFont:[UIFont systemFontOfSize:24 weight:UIFontWeightRegular]]; [[self diaryHelloLabel] setText:greetingValue]; [[self diaryHelloLabel] setTextAlignment:NSTextAlignmentCenter]; [[self diaryHelloLabel] setAlpha:0]; [[self diaryHelloLabel] setHidden:YES]; [self addSubview:[self diaryHelloLabel]]; [[self diaryHelloLabel] setTranslatesAutoresizingMaskIntoConstraints:NO]; [NSLayoutConstraint activateConstraints:@[ [self.diaryHelloLabel.topAnchor constraintEqualToAnchor:self.topAnchor constant:150], [self.diaryHelloLabel.leadingAnchor constraintEqualToAnchor:self.leadingAnchor], [self.diaryHelloLabel.trailingAnchor constraintEqualToAnchor:self.trailingAnchor], ]]; } } %new - (void)initHelloViewWithAnimation:(int)animation { // set hello view up if (!enableHelloSwitch) return; if (enableMediaPlayerSwitch && ![[self diaryPlayerView] isHidden]) return; [[self diaryHelloIconView] stopAnimating]; [[self diaryHelloIconView] removeFromSuperview]; self.diaryHelloIconView = nil; if (animation == 0) { helloStartArray = [NSMutableArray new]; for (int i = 0; i < 24; i++) [helloStartArray addObject:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"/Library/PreferenceBundles/DiaryPreferences.bundle/hello/start/%i.png", i]]]; helloStartImage = [UIImage animatedImageWithImages:helloStartArray duration:0.6]; self.diaryHelloIconView = [[UIImageView alloc] initWithImage:helloStartImage]; helloSearchingArray = nil; helloSearchingImage = nil; helloAuthenticatedArray = nil; helloAuthenticatedImage = nil; } else if (animation == 1) { helloSearchingArray = [NSMutableArray new]; for (int i = 0; i < 116; i++) [helloSearchingArray addObject:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"/Library/PreferenceBundles/DiaryPreferences.bundle/hello/searching/%i.png", i]]]; helloSearchingImage = [UIImage animatedImageWithImages:helloSearchingArray duration:4.28]; self.diaryHelloIconView = [[UIImageView alloc] initWithImage:helloSearchingImage]; helloStartArray = nil; helloStartImage = nil; helloAuthenticatedArray = nil; helloAuthenticatedImage = nil; } else if (animation == 2) { helloAuthenticatedArray = [NSMutableArray new]; for (int i = 0; i < 51; i++) [helloAuthenticatedArray addObject:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"/Library/PreferenceBundles/DiaryPreferences.bundle/hello/authenticated/%i.png", i]]]; helloAuthenticatedImage = [UIImage animatedImageWithImages:helloAuthenticatedArray duration:1.12]; self.diaryHelloIconView = [[UIImageView alloc] initWithImage:helloAuthenticatedImage]; helloStartArray = nil; helloStartImage = nil; helloSearchingArray = nil; helloSearchingImage = nil; } [[self diaryHelloIconView] setContentMode:UIViewContentModeScaleAspectFit]; [[self diaryHelloIconView] setClipsToBounds:YES]; [[self diaryHelloIconView] setHidden:NO]; if (![[self diaryHelloIconView] isDescendantOfView:self]) [self addSubview:[self diaryHelloIconView]]; [[self diaryHelloIconView] setTranslatesAutoresizingMaskIntoConstraints:NO]; [NSLayoutConstraint activateConstraints:@[ [self.diaryHelloIconView.topAnchor constraintEqualToAnchor:self.topAnchor constant:50], [self.diaryHelloIconView.centerXAnchor constraintEqualToAnchor:self.centerXAnchor], [self.diaryHelloIconView.heightAnchor constraintEqualToConstant:80], [self.diaryHelloIconView.widthAnchor constraintEqualToConstant:80], ]]; } %new - (void)playHelloStartAnimation { // play hello start animation if (!enableHelloSwitch) return; if (enableMediaPlayerSwitch && ![[self diaryPlayerView] isHidden]) return; shouldPlaySearchAnimation = YES; [self initHelloViewWithAnimation:0]; [[self diaryHelloIconView] setAnimationRepeatCount:1]; [[self diaryHelloIconView] startAnimating]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [self playHelloSearchingAnimation]; }); } %new - (void)playHelloSearchingAnimation { // play hello searching animation if (!enableHelloSwitch) return; if (enableMediaPlayerSwitch && ![[self diaryPlayerView] isHidden]) return; if (!shouldPlaySearchAnimation) return; [self initHelloViewWithAnimation:1]; [[self diaryHelloIconView] setAnimationRepeatCount:0]; [[self diaryHelloIconView] startAnimating]; if (showHelloGreetingSwitch) [[self diaryHelloLabel] setAlpha:0]; } %new - (void)playHelloAuthenticatedAnimation { // play hello authenticated animation if (!enableHelloSwitch) return; if (enableMediaPlayerSwitch && ![[self diaryPlayerView] isHidden]) return; shouldPlaySearchAnimation = NO; [self initHelloViewWithAnimation:2]; [[self diaryHelloIconView] setAnimationRepeatCount:1]; [[self diaryHelloIconView] startAnimating]; if (showHelloGreetingSwitch) { NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter]; [UIView animateWithDuration:0.25 delay:0.4 options:UIViewAnimationOptionCurveEaseInOut animations:^{ [[self diaryHelloLabel] setHidden:NO]; [[self diaryHelloLabel] setAlpha:1]; [notificationCenter postNotificationName:@"diaryUpdateNotificationList" object:nil]; } completion:^(BOOL finished) { [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ [[self diaryHelloLabel] setAlpha:0]; } completion:^(BOOL finished) { [[self diaryHelloIconView] setHidden:YES]; [[self diaryHelloLabel] setHidden:YES]; [[self diaryHelloIconView] removeFromSuperview]; [notificationCenter postNotificationName:@"diaryUpdateNotificationList" object:nil]; }]; }]; } else { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.8 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ [[self diaryHelloIconView] setHidden:YES]; [[self diaryHelloIconView] removeFromSuperview]; [[NSNotificationCenter defaultCenter] postNotificationName:@"diaryUpdateNotificationList" object:nil]; }); } } %end %hook CSCoverSheetViewController - (void)viewDidDisappear:(BOOL)animated { // remove hello view when lock screen disappeared %orig; // free up memory when hello is not visible [[coverSheetView diaryHelloIconView] stopAnimating]; [[coverSheetView diaryHelloIconView] removeFromSuperview]; helloStartArray = nil; helloStartImage = nil; helloSearchingArray = nil; helloSearchingImage = nil; helloAuthenticatedArray = nil; helloAuthenticatedImage = nil; } %end %hook SBLockScreenManager - (void)lockUIFromSource:(int)arg1 withOptions:(id)arg2 { // remove hello view when device was locked %orig; // free up memory when hello is not visible isLockedHello = YES; isScreenOnHello = NO; [[coverSheetView diaryHelloIconView] stopAnimating]; [[coverSheetView diaryHelloIconView] removeFromSuperview]; helloStartArray = nil; helloStartImage = nil; helloSearchingArray = nil; helloSearchingImage = nil; helloAuthenticatedArray = nil; helloAuthenticatedImage = nil; } %end %hook SBBacklightController - (void)turnOnScreenFullyWithBacklightSource:(long long)arg1 { // update diary when screen turns on %orig; if (![[%c(SBLockScreenManager) sharedInstance] isLockScreenVisible]) return; // this method gets called not only when the screen gets turned on, so i verify that it was turned on by checking if the lock screen is visible if (!isScreenOnHello) [coverSheetView playHelloStartAnimation]; [[NSNotificationCenter defaultCenter] postNotificationName:@"diaryUpdateNotificationList" object:nil]; isScreenOnHello = YES; } %end %hook SBDashBoardBiometricUnlockController - (void)setAuthenticated:(BOOL)arg1 { // play authenticated animation when unlocked with biometrics %orig; if (arg1 && isLockedHello) { isLockedHello = NO; [coverSheetView playHelloAuthenticatedAnimation]; } } %end %end
内容的提问来源于stack exchange,提问作者RustySpoon
相关产品推荐
相关产品推荐

