Created
October 7, 2025 04:21
-
-
Save CH3COOH/3da1417856ea3626f6e19e7bae027d09 to your computer and use it in GitHub Desktop.
Xcode 26.0 + iOS 26.0 の組み合わせで NavigationStack の Large Titleを表示させると、タイトルが背景色の裏に隠れてしまう不具合
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ContentView.swift | |
| // SampleNavigationTitle | |
| // | |
| // Created by wada.kenji on 2025/10/07. | |
| // | |
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| NavigationStack { | |
| List { | |
| ForEach(0 ..< 20) { index in | |
| Text("Item \(index)") | |
| } | |
| } | |
| .navigationTitle(Text("タイトル")) | |
| .defaultNavigationBar() | |
| } | |
| } | |
| } | |
| struct CustomNavigationBarModifier: ViewModifier { | |
| init() { | |
| let appearance = UINavigationBarAppearance() | |
| appearance.configureWithOpaqueBackground() | |
| appearance.backgroundColor = .green | |
| // // タイトルが背景の裏側に存在している | |
| // appearance.backgroundColor = .green.withAlphaComponent(0.5) | |
| appearance.largeTitleTextAttributes = [ | |
| .font: UIFont.systemFont(ofSize: 30, weight: .heavy), | |
| .foregroundColor: UIColor.black, | |
| ] | |
| appearance.titleTextAttributes = [ | |
| .font: UIFont.systemFont(ofSize: 15, weight: .regular), | |
| .foregroundColor: UIColor.black, | |
| ] | |
| UINavigationBar.appearance().standardAppearance = appearance | |
| UINavigationBar.appearance().scrollEdgeAppearance = appearance | |
| } | |
| func body(content: Content) -> some View { | |
| ZStack { content } | |
| } | |
| } | |
| extension View { | |
| func defaultNavigationBar() -> some View { | |
| modifier(CustomNavigationBarModifier()) | |
| } | |
| } | |
| #Preview { | |
| ContentView() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment