Post

Replies

Boosts

Views

Activity

Reply to SwiftUI - Navigation Bar Fails to Switch From Scroll Edge Appearance
You might want to consider implementing a Navigation Bar Appearance ViewModifier and applying it to your VStack struct MainView: View { var body: some View { ScrollView { Text("Text") } .frame(maxWidth: .infinity) } } struct TabBarView: View { var body: some View { Color.pink .frame(maxWidth: .infinity) .frame(height: 55) } } struct ContentView: View { var body: some View { NavigationView { VStack(spacing: 0) { MainView() TabBarView() // Commenting this out fixes the problem. } .background(.red) // Commenting this out _also_ fixes the problem. .opaqueNavigationBar( foregroundColor: .white, backgroundColor: .systemBrown, tintColor: .systemIndigo, shadowColor: .darkGray) .navigationBarTitleDisplayMode(.inline) .navigationTitle("Main View") } } } public struct OpaqueNavigationBarAppearance: ViewModifier { public init( font: UIFont = .preferredFont(forTextStyle: .headline), largeTitleFont: UIFont = .preferredFont(forTextStyle: .largeTitle), foregroundColor: UIColor = .clear, backgroundColor: UIColor = .secondarySystemBackground, tintColor: UIColor = .clear, shadowColor: UIColor = .clear) { let appearance = UINavigationBarAppearance() appearance.configureWithOpaqueBackground() appearance.titleTextAttributes = [.foregroundColor: foregroundColor, .font: font] appearance.largeTitleTextAttributes = [.foregroundColor: foregroundColor, .font: largeTitleFont] appearance.shadowColor = shadowColor appearance.backgroundColor = backgroundColor UINavigationBar.appearance().standardAppearance = appearance UINavigationBar.appearance().scrollEdgeAppearance = appearance UINavigationBar.appearance().compactAppearance = appearance UINavigationBar.appearance().tintColor = tintColor } public func body(content: Content) -> some View { return content } } public extension View { func opaqueNavigationBar( font: UIFont = .preferredFont(forTextStyle: .headline), largeTitleFont: UIFont = .preferredFont(forTextStyle: .largeTitle), foregroundColor: UIColor = .clear, backgroundColor: UIColor = .secondarySystemBackground, tintColor: UIColor = .clear, shadowColor: UIColor = .clear) -> some View { ModifiedContent( content: self, modifier: OpaqueNavigationBarAppearance( font: font, largeTitleFont: largeTitleFont, foregroundColor: foregroundColor, backgroundColor: backgroundColor, tintColor: tintColor, shadowColor: shadowColor)) } }
Topic: UI Frameworks SubTopic: UIKit Tags:
May ’23
Reply to Widget background Image not loading IOS 17 Xcode
Here's a sample implementation of containerBackground. LMEntryView is your widget view. struct LMWidget: Widget { var supportedFamilies: [WidgetFamily] { [.systemSmall, .systemMedium] } var body: some WidgetConfiguration { StaticConfiguration(kind: "LMWidget", provider: LMTimelineProvider()) { entry in if #available(iOS 17, *) { LMEntryView(entry: entry) .frame(maxWidth: .infinity, maxHeight: .infinity) .containerBackground(Color("WidgetBackground"), for: .widget) } else { LMEntryView(entry: entry) .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color("WidgetBackground")) } } .configurationDisplayName("L_M_Widget_Title".localized) .description("L_M_Widget_Description".localized) .supportedFamilies(supportedFamilies) .contentMarginsDisabled() } }
Jan ’24
Reply to iOS26 bottom toolbars space broken
.toolbar { ToolbarItemGroup(placement: .bottomBar) { GlassEffectContainer { Button { // } label: { VStack { Image( systemName: "car" ) Text("Car") .font(.caption2) } .padding() } .tint(.red) Button { // } label: { VStack { Image( systemName: "person" ) Text("Person") .font(.caption2) } .padding() } .tint(.blue) Button { } label: { VStack { Image( systemName: "house" ) Text("House") .font(.caption2) } .padding() } .tint(.green) Button { } label: { VStack { Image( systemName: "lightbulb" ) Text("Lightbulb") .font(.caption2) } .padding() } .tint(.indigo) Button { } label: { VStack { Image( systemName: "trash" ) Text("Trash") .font(.caption2) } .padding() } .tint(.purple) } .frame(alignment: .leadingLastTextBaseline) .frame(height: 64) .frame(maxWidth: .infinity) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’25
Reply to Setting Tint Color for Prominent Style UIBarButtonItems at App Level in iOS26
let image1 = UIImage( systemName: "person" ) let barButtonItem1 = UIBarButtonItem.init( image: image1, style: .plain, target: nil, action: nil ) barButtonItem1.tintColor = .systemPink let image2 = UIImage( systemName: "book" ) let barButtonItem2 = UIBarButtonItem.init( image: image2, style: .plain, target: nil, action: nil ) barButtonItem2.tintColor = .systemMint navigationItem.rightBarButtonItems = [ barButtonItem1, flexibleSpace, barButtonItem2 ]
Topic: UI Frameworks SubTopic: UIKit Tags:
Aug ’25