12.2 C
Canberra
Friday, January 23, 2026

Tips on how to have non-sticky toolbar background in SwiftUI [closed]


I’ve taken a liking to a couple specific apps which have a colour/background behind their toolbar on the prime of the view, as if to emphasise the navigation titles/headers, however then you may scroll previous it.

I am focusing on iOS 26. That is principally what I’ve thus far, which leaves me a traditional coloured toolbar, that is sticky:

struct ContentView: View {
    var physique: some View {
        NavigationStack {
            ScrollView {
                ForEach(0..<50, id: .self) { index in
                    Textual content("(index)")
                }
                .body(maxWidth: .infinity)
            }
            .toolbarBackground(.blue, for: .navigationBar)
            .toolbarBackground(.seen, for: .navigationBar)
            .toolbar {
                ToolbarItem(placement: .topBarLeading) {
                    Textual content("Title")
                        .fontWeight(.daring)
                        .font(.title2)
                        .fixedSize()
                }
                .sharedBackgroundVisibility(.hidden)
            }
        }
    }
}

Which yields a semi clear sticky header colour:
Tips on how to have non-sticky toolbar background in SwiftUI [closed]

I’ve experimented with conditionally setting .toolbarBackground(.seen/.hidden...) to diverse success, which additionally is not non-sticky, simply adjustments the opacity.

Anybody know the way to do that? Instance screenshots under from Slack app, earlier than and after scrolling down. On this case, it appears to be like like their title can be non-sticky nonetheless.

I am open to utilizing UIKit right here too.

That is what I am going for, observe that the header is purple solely when on the prime of the web page, however fades out slowly, and it additionally has a "laborious" line on the backside that recedes as I scroll upwards.
slack non-sticky toolbar background

(sorry about dangerous gif high quality – wanted to compress to add)

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles