Is there a better way for the Custom Logo implementation?

This commit is contained in:
arichornlover 2023-11-25 18:49:58 -06:00 committed by GitHub
parent 69dc003517
commit 5197eacd2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -145,17 +145,23 @@ static void repositionCreateTab(YTIGuideResponse *response) {
// uYouPlusExtra Logo - #183
%group gDefaultYouTubeLogo
%hook YTHeaderLogoController
- (id)logoView {
id originalLogoView = %orig;
if (originalLogoView) {
if (self.pageStyle == 0) {
[self customLogoWithImageName:@"youtube_logo.png"];
} else if (self.pageStyle == 1) {
[self customLogoWithImageName:@"youtube_logo_dark.png"];
}
}
return originalLogoView;
}
%new
- (void)customLogo {
if (self.pageStyle == 0) {
UIImageView *customLogoView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 122, 48)];
customLogoView.image = [UIImage imageWithContentsOfFile:@"/Library/Application Support/uYouPlus.bundle/youtube_logo.png"];
[self.logoView addSubview:customLogoView];
} else if (self.pageStyle == 1) {
UIImageView *customLogoView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 122, 48)];
customLogoView.image = [UIImage imageWithContentsOfFile:@"/Library/Application Support/uYouPlus.bundle/youtube_logo_dark.png"];
[self.logoView addSubview:customLogoView];
}
- (void)customLogoWithImageName:(NSString *)imageName {
UIImageView *customLogoView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 122, 48)];
customLogoView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"/Library/Application Support/uYouPlus.bundle/%@", imageName]];
UIView *logoView = [self valueForKey:@"logoView"];
[logoView addSubview:customLogoView];
}
%end