HomeiOS DevelopmentIncluding customized toolbar header in iOS 26

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 dwelling 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

Nonetheless, when tried on iOS 26, the toolbar is proven a bit otherwise, as proven under

Code for the House display and customized header

ScrollView {
            Group {
               //Code for grid record
            }
            .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(Colour.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

- Advertisment -
Google search engine

Most Popular

Recent Comments