我正在使用CarPlay框架开发CarPlay应用程序。
我使用CPNowPlayingImageButton在NowPlaying模板上显示自定义按钮。
https://developer.apple.com/documentation/carplay/cpnowplayingimagebutton?language=objc
创建了ImageAsset镜像,

然后创建CPNowPlayingImageButton。
UIImage* image = [UIImage imageNamed:@"carplay_heart" inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:self.interfaceController.carTraitCollection];
CPNowPlayingImageButton* button = [CPNowPlayingImageButton.alloc initWithImage:image handler:^(CPNowPlayingImageButton*)
{
JPlaylistUtils::CurrentToggleFavorite(FALSE, TRUE, nil);
}];
[CPNowPlayingTemplate.sharedTemplate updateNowPlayingButtons:@[button]];
我期望在浅色外观上显示黑色图像,在深色外观上显示白色图像,但CarPlay在深色外观上显示的总是黑色(浅色主题)图像,并且图像尺寸太小。

如果我在CarPlay /设置中更改了外观,第一次显示的图像就像预期的那样。

但是如果更新按钮,CarPlay会再次显示错误的图像。
发布于 2021-10-26 16:44:40
我建议您只使用一个图像,并让CarPlay通过设置渲染为模板图像来计算明/暗模式着色。你的图片有哪些尺寸?
https://stackoverflow.com/questions/69684507
复制相似问题