Текущая реализация
Я использую CPNowPlayingTemplate со стандартной реализацией:
Код: Выделить всё
import CarPlay
final class CarPlayNowPlayingViewModel: NSObject, CPNowPlayingTemplateObserver {
private let nowPlayingTemplate = CPNowPlayingTemplate.shared
override init() {
super.init()
nowPlayingTemplate.add(self)
setupTemplate()
}
private func setupTemplate() {
// These are the ONLY properties I can find for the queue button:
nowPlayingTemplate.isUpNextButtonEnabled = true
nowPlayingTemplate.upNextTitle = "Queue"
}
// Handle queue button tap
func nowPlayingTemplateUpNextButtonTapped(_ nowPlayingTemplate: CPNowPlayingTemplate) {
// Can only control navigation, not button appearance
navigateToQueue()
}
}
< /code>
Что я могу в настоящее время настроить < /h3>
Структура только раскрывает эти два свойства для кнопки очереди: < /p>
// ✅ These work:
nowPlayingTemplate.isUpNextButtonEnabled = true/false // Show/hide button
nowPlayingTemplate.upNextTitle = "Custom Text" // Button label text
< /code>
Что я хочу настроить (но не могу) < /h3>
// ❌ These properties don't exist:
nowPlayingTemplate.upNextButtonIcon = customIcon // Custom icon
nowPlayingTemplate.upNextButtonColor = .systemBlue // Custom color
nowPlayingTemplate.upNextButtonPosition = .leading // Custom position
nowPlayingTemplate.upNextButtonStyle = .prominent // Custom style
Интересно, что я МОГУ создавать полностью собственные кнопки для других функций:
Код: Выделить всё
// ✅ Custom buttons work fine for other actions:
private lazy var favoriteButton: CPNowPlayingImageButton = CPNowPlayingImageButton(
image: UIImage(systemName: "heart")?.withRenderingMode(.alwaysTemplate)
) { [weak self] _ in
self?.toggleFavorite()
}
private lazy var customActionButton: CPNowPlayingImageButton = CPNowPlayingImageButton(
image: UIImage(systemName: "star.fill")?.withRenderingMode(.alwaysTemplate)
) { [weak self] _ in
self?.performCustomAction()
}
// Add custom buttons to template
nowPlayingTemplate.updateNowPlayingButtons([favoriteButton, customActionButton])
< /code>
Попытка решений < /h3>
[b] 1. Попробовал создать пользовательскую кнопку очереди: [/b]
// ❌ This doesn't replace the system queue button
private lazy var customQueueButton: CPNowPlayingImageButton = CPNowPlayingImageButton(
image: UIImage(systemName: "list.bullet")
) { [weak self] _ in
self?.navigateToQueue()
}
// The system queue button still appears separately
Код: Выделить всё
// ❌ Cannot subclass - it's designed to use .shared singleton
class CustomNowPlayingTemplate: CPNowPlayingTemplate {
// Compiler error: CPNowPlayingTemplate cannot be subclassed
}
Код: Выделить всё
// ❌ No public API to access the queue button view
// nowPlayingTemplate.upNextButton // Property doesn't exist
Есть ли способ настроить внешний вид кнопки очереди CarPlay за пределами текста заголовка? Кнопка? /> < /li>
< /ol>
среда < /h3>
ios 15.0+< /li>
Carplay Framework < /li>
xcode 14+< /li>
wift 5.7+< />
< /br /> < /br /> < /br /> < /br /> < /br /> < /br /> < /hcode 14+< /li>
wift 5.7+< />
< /br /3 < /br /hcode 14+< /li>
. Поведение < /h3>
Я ожидаю, что смогу настроить внешний вид кнопки очереди (значок, цвет, стиль), похожий на то, как я могу настроить другие кнопки Carplay или, по крайней мере, иметь документацию, объясняющая, почему эта конкретная кнопка ограничена. Будьте полностью настроены.>
Подробнее здесь: https://stackoverflow.com/questions/797 ... tton-appea
Мобильная версия