Search results for

swiftui

16,623 results found

Post

Replies

Boosts

Views

Activity

Reply to SwiftUI List with Geometry header behavior changed after building app with Xcode 26
As promised, here is the SwiftUI view code that uses this modifier: code-block import SwiftUI struct GridListView: View { @State private var paddingToTop: CGFloat = 68.0 private let expandedPaddingToTop: CGFloat = 68.0 private let paddingBetweenL2AndL3: CGFloat = 24.0 private let L3Height: CGFloat = 44.0 @State private var items: [Int] = Array(1...100) @State private var isLoading: Bool = false private var L3Opacity: CGFloat { pow(paddingToTop / expandedPaddingToTop, 5) } private var L3YOffset: CGFloat { -L3Height + (paddingToTop - paddingBetweenL2AndL3) } var body: some View { ZStack { List { // Show loaded items ForEach(Array(stride(from: 0, to: items.count, by: 2)), id: .self) { index in HStack { GridItemView(item: items[index]) if index + 1 < items.count { GridItemView(item: items[index + 1]) } else { Spacer() } } .listRowInsets(EdgeInsets()) .padding(.vertical, 8) .onAppear { // Detect when user reaches near the end if index == items.count - 2 { loadMoreItemsIfNeeded() } } } // Show
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Alert within Popover is clipped in height causing title to be hidden
When showing an Alert from within a Popover that has a fixed height, the newly presented Alert is in the same position but gets limited by the Popovers height causing the title of the Alert to be hidden. Is this intentional behavior or are Alerts not supported within Popovers and I'd have to pass it through to my main view? Code: // // DemoalertPopover.swift // ******** // // Created by Thilo on 26.06.2023. // import SwiftUI struct DemoAlertPopover: View { @Environment(.dismiss) var dismiss @State private var showDeleteConfirmation = false let dateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = dd.MM.yyyy return formatter }() var body: some View { VStack(alignment: .leading, spacing: 0) { HStack { Text(Title).font(.extraLargeTitle).lineLimit(1) Spacer() Button(action: { dismiss() }) { Label(Close, systemImage: xmark).labelStyle(.iconOnly) } } HStack(alignment: .center) { Text(Content).font(.largeTitle) Text(Content2).foregroundStyle(.secondary) } LazyVGrid(columns:
2
0
839
Oct ’25
Reply to SwiftUI safe area stays offset after keyboard dismissal with “Reduce Motion” + “Prefer Cross-Fade” enabled (iOS 26)
Seeing the same thing, here's a small reproduction: import SwiftUI struct ContentView: View { @State private var text = @FocusState private var isTextFocused @Environment(.accessibilityReduceMotion) private var reduceMotion var body: some View { List { TextField(Input, text: $text) .focused($isTextFocused) .onSubmit { isTextFocused.toggle() } Text(Focus the text field then dismiss the keyboard) Text(Observe how the safe area doesn't change when dismissing the keyboard in iOS 26 with the below accessibility settings enabled.) Label(Reduce Motion? (reduceMotion ? true: false), systemImage: accessibility) Label( Prefer Cross-Fade Transitions? (UIAccessibility.prefersCrossFadeTransitions ? true: false), systemImage: accessibility ) } .scrollDismissesKeyboard(.immediately) .textFieldStyle(.roundedBorder) .border(.red) .safeAreaInset(edge: .bottom) { HStack { Text(This is in the safe area insets) Spacer() Button(Close Keyboard) { isTextFocused.toggle() } .buttonStyle(.borderedProminent) } .padding() .bord
Oct ’25
Reply to .sheet and focus elements inside
Yeah, that’s a known issue with custom detents in SwiftUI sheets — keyboard focus navigation often breaks when using fixed heights. For now, you can try using .medium or .large detents instead, or manage focus manually with @FocusState as a workaround.
Topic: UI Frameworks SubTopic: SwiftUI
Oct ’25
SwiftUI's tabViewBottomAccessory API Cannot Control Visibility in iOS 26.1
In iOS 26.1, SwiftUI's tabViewBottomAccessory API cannot control visibility properly. The tabViewBottomAccessory remains always visible, which is inconsistent with the behavior in iOS 26.0 / iOS 26.0.1. ` struct ContentView: View { enum Tabs { case first } @State private var selection: Tabs = .first @State private var showBottomAccessory: Bool = true var body: some View { tabView } var tabView: some View { TabView(selection: $selection) { Tab(value: .first) { content } label: { VStack { Text(first) } } } .tabViewBottomAccessory { if showBottomAccessory { Text(BottomAccessory) } } } var content: some View { Button(change) { showBottomAccessory.toggle() } } } `
Topic: UI Frameworks SubTopic: SwiftUI
6
0
348
Oct ’25
Reply to 'tabViewBottomAccessory' leaves an empty container when conditionally hidden
I’m currently shipping a production app using .tabViewBottomAccessory in SwiftUI (tested and stable on iOS 26.0). After testing on iOS 26.1, I’ve noticed that when the accessory view is conditionally hidden, the space it occupies remains visible — an empty gap appears right above the tab bar. This regression will negatively impact users once iOS 26.1 rolls out. FB20772048
Topic: Design SubTopic: General
Oct ’25
'tabViewBottomAccessory' leaves an empty container when conditionally hidden
We use SwiftUI's .tabViewBottomAccessory in our iOS apps for displaying an Audio MiniPlayer View (like in the Apple Music App). TabView(selection: $viewModel.selectedTab) { // Tabs here } .tabViewBottomAccessory { if viewModel.showAudioMiniPlayer { MiniPlayerView() } } The Problem This code works perfectly on iOS 26.0. When 'viewModel.showAudioMiniPlayer' is 'false', the accessory is completely hidden. However, on iOS 26.1 (23B5059e), when 'viewModel.showAudioMiniPlayer' is 'false', the MiniPlayerView disappears, but an empty container remains, leaving a blank space above the tab bar. Is this a known Bug in iOS 26.1 and are there any effective workarounds or should I just wait until Apple fixed it?
Topic: Design SubTopic: General
4
0
1.7k
Oct ’25
WorkoutKit WorkoutScheduler sync Broken with iOS 18.2 beta
WorkoutKit WorkoutScheduler seems broken with the first beta of iOS 18.2. I have tested using my app from Xcode and the one that is on the App Store (and working properly on other devices), and it's not working with this new beta of iOS. They appears in WorkoutScheduler.shared.scheduledWorkouts, but not on the watch. I even tried with other apps that do the same with Manual add to Apple Watch with SwiftUI workoutPreview work. Xcode 16.0 iOS 18.2 Beta 1 WatchOS 11.1
29
0
2k
Oct ’25
SwiftData: Unexpected backing data for snapshot creation
When deleting a SwiftData entity, I sometimes encounter the following error in a document based SwiftUI app: Fatal error: Unexpected backing data for snapshot creation: SwiftData._FullFutureBackingData The deletion happens in a SwiftUI View and the code used to retrieve the entity is standard (the ModelContext is injected from the @Environment): let myEntity = modelContext.model(for: entityIdToDelete) modelContext.delete(myEntity) Unfortunately, I haven't yet managed to isolate this any further in order to come up with a reproducible PoC. Could you give me further information about what this error means?
3
0
228
Oct ’25
Issues with Searchable Modifier Placement and State in TabView on iOS 26
Hi everyone, I'm updating my app to adopt the new search bar design in iOS 26 and I'm running into some UI issues depending on the implementation pattern. I'm using Xcode 26.0.1 and SwiftUI 6. I've tried two main approaches for search, and each has a specific problem related to TabView. Pattern 1: Searchable View Inside a Standard Tab In this pattern, the search bar is specific to one of the main tabs. The Code: struct ContentView: View { var body: some View { TabView { Tab(Main, systemImage: list.bullet) { MainView() } Tab(View1, systemImage: gearshape) { Text(View1) } Tab(View2, systemImage: gearshape) { Text(View2) } } } } struct MainView: View { @State private var searchText = var body: some View { NavigationStack { List { Text(Text 1) Text(Text 2) } .searchable(text: $searchText, placement: .toolbar) .navigationTitle(Main) } } } The Problem: When I preview MainView directly, the search bar correctly appears at the bottom, matching the new iOS 26 design. However, when MainView is presented insid
1
0
105
Oct ’25
Reply to Exporting and restoring AttributedString in rich TextEditor (iOS 26)
Yeah, converting AttributedString to NSAttributedString and then to Data with NSAttributedString.DocumentType.rtf will lose SwiftUI attributes (because SwiftUI attributes aren't represented in an ObjC-based NSAttributedString), unless you convert the SwiftUI attributes to UIKit / AppKit attributes with your own code. You can convert AttributedString directly to RTF / RTFD data using AttributedTextFormatting.Transferable, which was newly introduced in iOS 26 and friends. The following code example shows how to do that: struct ContentView: View { @Environment(.self) private var environment ... private func attributedStringToRTF() async { var attributedString = AttributedString(inputText) attributedString.backgroundColor = .red print(Input: attributedString = (attributedString)) let transferable = AttributedTextFormatting.Transferable(text: attributedString, in: environment) guard let rtfData = try? await transferable.exported(as: .rtf) else { return } guard let transferrable2 = try? a
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’25
Simulator causing Mac audio distortion
I am experiencing an issue where my Mac's speakers will crackle and pop when running an app on the Simulator or even when previewing SwiftUI with Live Preview. I am using a 16 MacBook Pro (i9) and I'm running Xcode 12.2 on Big Sur (11.0.1). Killing coreaudiod temporarily fixes the problem however this is not much of a solution. Is anyone else having this problem?
17
0
13k
Oct ’25
SwiftUI document based app: weird NavBar colors since iOS 26
I have multiple document based SwiftUI apps without any NavigationBar customization. Since upgrading to iOS 26 , when these apps launch, sometimes their navigation bar icons appear grey (as if only the button shadows were showing) and the document title is white, so it’s invisible. One of the apps has an Inspector: here, whenever the Inspector appears, the colors are correct. This behavior has been consistent since the first iOS 26 developer beta and can be reproduced on iOS 26.1 beta 23B5064e. So far I have only managed to reproduce this in light mode.
1
0
135
Oct ’25