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 // uYouPlusExtra Logo - #183
%group gDefaultYouTubeLogo %group gDefaultYouTubeLogo
%hook YTHeaderLogoController %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 %new
- (void)customLogo { - (void)customLogoWithImageName:(NSString *)imageName {
if (self.pageStyle == 0) { UIImageView *customLogoView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 122, 48)];
UIImageView *customLogoView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 122, 48)]; customLogoView.image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"/Library/Application Support/uYouPlus.bundle/%@", imageName]];
customLogoView.image = [UIImage imageWithContentsOfFile:@"/Library/Application Support/uYouPlus.bundle/youtube_logo.png"]; UIView *logoView = [self valueForKey:@"logoView"];
[self.logoView addSubview:customLogoView]; [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];
}
} }
%end %end