21.7 C
Canberra
Tuesday, October 21, 2025

Including customized toolbar header in iOS 26


I am new to iOS growth and SwiftUI, and I’ve a customized header view that I wish to place on my residence display. I positioned the view within the toolbar block wrapped with a ToolbarItem with .principal placement. It really works as anticipated in pre iOS 26, as proven within the picture

Including customized toolbar header in iOS 26

Nevertheless, when tried on iOS 26, the toolbar is proven a bit in a different way, as proven under

Code for the House display and customized header

ScrollView {
            Group {
               //Code for grid listing
            }
            .navigationTitle(Localizations.homeTabKey)
            .navigationBarTitleDisplayMode(.inline)
            .toolbar {
                ToolbarItem(placement: .principal) {
                    SearchHeaderView(onTap: {
                        coordinator.push(.search, sort: .fullScreenCover)
                    }).padding(.backside, 8).body(maxWidth: .infinity)
                }
            }
        }

SearchHeaderView


struct SearchHeaderView: View {
    let onTap: () -> Void
    let onCameraAction: () -> Void
    let onMicAction: () -> Void

    init(
        onTap: @escaping () -> Void = {},
        onCameraAction: @escaping () -> Void = {},
        onMicAction: @escaping () -> Void = {}
    ) {
        self.onTap = onTap
        self.onCameraAction = onCameraAction
        self.onMicAction = onMicAction
    }

    var physique: some View {
        HStack {
            Textual content(Localizations.search)
                .foregroundColor(.ratingForeground)
                .font(.system(measurement: 14))
                .padding(.horizontal, 8)
            Spacer()
            ActionButtonsView(
                onCameraAction: {

                },
                onMicAction: {

                }
            ).padding(.horizontal, 8)
        }.body(maxWidth: .infinity)
        .overlay(
            RoundedRectangle(cornerRadius: 6)
                .stroke(lineWidth: 0.8)
                .foregroundColor(
                    Constants.activeColorPalette.searchStroke
                )
        ).background(
            Rectangle()
                .fill(Coloration.clear)
                .contentShape(Rectangle())
                .onTapGesture {
                    onTap()
                }
        )
    }
}

How can I obtain related habits in iOS 26? I’ve tried altering the position of the toolbar merchandise and setting maxWidth to infinity, however nothing appears to work.

Any assistance is appreciated, and Thanks for taking the time to learn over this.

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