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