[img]https://i.sstatic.net /Umkaa7VE.png[/img]
Я тоже хочу сохранить функциональность слайдера назад.
Из вопроса на форуме Apple, заданного год назад, что Я пытаюсь сделать это «официально не поддерживается». Тем не менее, я хотел бы задать вопрос здесь, о переполнении стека.
Мне нужно четко различать реальный символ и текст кнопки.
Пока что , я выяснил три вещи:
- Вы можете скрыть стандартную панель навигации и тень, выполнив следующие действия:
Код: Выделить всё
// Set up the UINavigationBarAppearance
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground() // Transparent background
appearance.shadowColor = nil // Remove shadow
appearance.backgroundColor = .clear // Clear background
// Apply appearance globally
UINavigationBar.appearance().standardAppearance = appearance
- Вы можете изменить стандартный символ навигации кнопки «chevron.backwards» на другой символ, предоставленный Apple, выполнив следующие действия:
Код: Выделить всё
// Set up the UINavigationBarAppearance
let appearance = UINavigationBarAppearance()
// Create a static black version of the back button image
let backImage = UIImage(systemName: [insert symbol name here])
appearance.setBackIndicatorImage(backImage, transitionMaskImage: backImage)
// Apply appearance globally
UINavigationBar.appearance().standardAppearance = appearance
- Вы можете настроить текст «Назад» стандартной навигации, выполнив следующие действия:
Код: Выделить всё
// Customize back button appearance
let backButtonAppearance = UIBarButtonItemAppearance(style: .plain)
backButtonAppearance.normal.titleTextAttributes = [
.font: UIFont.systemFont(ofSize: 16, weight: .medium),
.foregroundColor: UIColor.black // Text color
]
appearance.backButtonAppearance = backButtonAppearance
// Apply appearance globally
UINavigationBar.appearance().standardAppearance = appearance
Код: Выделить всё
struct StartupPage2: View {
init() {
// Set up the UINavigationBarAppearance
let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground() // Transparent background
appearance.shadowColor = nil // Remove shadow
appearance.backgroundColor = .clear // Clear background
// Customize back button appearance
let backButtonAppearance = UIBarButtonItemAppearance(style: .plain)
backButtonAppearance.normal.titleTextAttributes = [
.font: UIFont.systemFont(ofSize: 16, weight: .medium), // Text font
.foregroundColor: UIColor.black // Text color
]
appearance.backButtonAppearance = backButtonAppearance
// Create a static black version of the back button image
let backImage = UIImage(systemName: "chevron.backward") // Change UIImage
appearance.setBackIndicatorImage(backImage, transitionMaskImage: backImage)
// Apply appearance globally
UINavigationBar.appearance().standardAppearance = appearance
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... sing-swift