Можно ли настроить внешний вид и поведение кнопки очереди CarPlay Now Playing «Up Next», помимо текста заголовка?IOS

Программируем под IOS
Ответить
Anonymous
 Можно ли настроить внешний вид и поведение кнопки очереди CarPlay Now Playing «Up Next», помимо текста заголовка?

Сообщение Anonymous »

Я работаю над приложением для потоковой передачи музыки, и мне нужно настроить кнопку очереди на экране CarPlay «Сейчас исполняется» (кнопка «Далее»). Я хочу изменить его внешний вид (значок, цвет, положение) и, возможно, его поведение, но я сталкиваюсь с ограничениями платформы Apple CarPlay.
Текущая реализация
Я использую 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
2. Попробовал создать подкласс CPNowPlayingTemplate:

Код: Выделить всё

// ❌ Cannot subclass - it's designed to use .shared singleton
class CustomNowPlayingTemplate: CPNowPlayingTemplate {
// Compiler error: CPNowPlayingTemplate cannot be subclassed
}
3. Попробовал доступ к кнопке напрямую:

Код: Выделить всё

// ❌ 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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»