41,767 questions
-1
votes
0
answers
26
views
How to completely remove the horizontal “ghost lines” inside List with Section and custom rows?
I’m working on a screen that uses a single SwiftUI List composed of:
a top block (statistics, month picker, year selector, total, Entrata/Uscita picker).
a list of transactions grouped by day, each ...
0
votes
0
answers
20
views
How does NSItemProvider handle NSAttributedString?
let provider = NSItemProvider()
if model.type == .rich {
if let attr = NSAttributedString(
with: model.data,
type: model.pasteboardType
...
0
votes
0
answers
44
views
How can I show a movable webcam preview above all windows in macOS without activating the app
I'm building a macOS app using SwiftUI, and I want to create a draggable floating webcam preview window
Right now, I have something like this:
import SwiftUI
import AVFoundation
struct ...
0
votes
0
answers
45
views
iOS 26.1: In TabView, NavigationStack animation breaks when intercepting tab selection to show fullScreenCover
I'm trying to show a fullScreenCover when the user taps the third tab instead of actually switching to that tab. The issue is that resetting selectedTab = oldValue in onChange breaks the ...
1
vote
0
answers
54
views
Using @Environment inside a ViewModifier causes a deep SwiftUI crash — is my theme setup fundamentally wrong?
I use a custom AppTheme type and inject it via a custom EnvironmentKey. Views can access the theme using @Environment(\.appTheme) or override it explicitly.
While this work fine in most cases it ...
0
votes
1
answer
70
views
Custom bottom sheet shows brief flicker/fade of underlying view when expanding/collapsing (iOS 15)
I’m building a reusable custom bottom sheet component in SwiftUI because my app supports iOS 15, so I can’t use .sheet with detents yet. Functionally everything works the sheet opens and closes but I’...
1
vote
1
answer
62
views
Custom strokeStyle lineCap with corner radius [duplicate]
I want to be able to give these ends a corner radius of 5 instead of sharp square ends.
lineCap only supports .round, .butt and .square
How can I create a custom corner radius for the lineCap?
Here is ...
Advice
0
votes
2
replies
43
views
CloudKit data initial share sheet in Swift UI and iOS 26
Let's use a basic todo app as an example - sharing a todo list. I have a share button (square with up arrow) that when the user taps I want the initial share sheet to appear. If I have to create and ...
3
votes
2
answers
64
views
Using .presentationBackground(_: Style), but default sheet background is still visible
I wanted to try out the new .presentationBackground modifier from iOS 16.4+ for a clear background in a Sheet. Stack Overflow posts like this suggest it's possible.
But the presentationBackground just ...
1
vote
1
answer
106
views
List view bottom edges not being clipped ios 26
before updating to iOS 26 my list was looking fine but now it has abnormal paddings and because I am using fixed height, I had to increase the height from 40 to 60 to fit the text.
There are currently ...
1
vote
1
answer
36
views
Realm Database Operations Causing UI Hangs and Scroll Lag During Extensive Read/Write (iOS 16, SwiftUI)
I have severe UI hang issues whenever my sync worker is running. The app experiences:
Screen navigation freezes
Scroll lag and stuttering
Unresponsive UI during data synchronization
The root cause is ...
-3
votes
0
answers
46
views
White capsule behind Button [duplicate]
Upgraded to iOS 26.1 and now getting a white capsule behind my StyleSheet buttons:
The View code is:
ToolbarItem(placement: .topBarLeading) {
Button {
...
1
vote
1
answer
74
views
How to present the new Game Center dashboard from within a SwiftUI app
I’m integrating achievements and leaderboards into my SwiftUI app and would like to present the Game Center dashboard directly from within SwiftUI. However, it seems the only supported way to show the ...
0
votes
2
answers
95
views
How to create an image carousel that auto-sizes based on it's content?
I’m trying to build an image carousel similar to the one in the App Store, but I'm a facing a lay-out issue.
The carousel should:
Automatically adjust its height based on its content
Automatically ...
2
votes
1
answer
67
views
Remote notification tap not handled when app is killed
I’m running into an issue with remote push notifications on iOS.
When the app is in background or inactive, tapping a notification correctly triggers:
userNotificationCenter(_:didReceive:...
Advice
0
votes
1
replies
58
views
How can I achieve the same search behaviour as in iOS 26 Wallet app?
So in iOS 26, the search field changed a bit where it can be at the bottom. While other apps have the search in the nav bar, wallet has it in the toolbar, so when it's pressed it changes to a ...
1
vote
2
answers
61
views
Increase height AND tappable area of TextField?
I'm having a difficult time trying to figure out how to increase both the height AND the tappable area of a TextField.
I've tried these three solutions, and none have worked for me. I still can't tap ...
1
vote
1
answer
49
views
.alert inside .fullScreenCover is immediately dismissed when used inside specific view hierachy
I have created a reusable ModalDialog view that presents modal content via .fullScreenCover. Inside this dialog, a button triggers a SwiftUI .alert.
This works fine in many situations. However, in a ...
Advice
1
vote
2
replies
32
views
SwiftUI onDelete() modifier
I’m trying to learn iOS swift UI development working through some of the Apple tutorials I came across this piece of code. I don’t understand how the onDelete modifier works. This may be more of a ...
1
vote
1
answer
50
views
Vertical paging using TabView breaks layout in SwiftUI
I'm working on vertical paging, using TabView. I put player code in TabView and rotate it to show vertical paging, but UI breaks.
Vertical Pager
struct EpisodeVerticalPager: View {
let episodes: ...
-1
votes
1
answer
70
views
How to reduce top padding of NavigationBar to match native Apple apps? [closed]
When I use navigationTitle in SwiftUI, the top padding becomes too large. However, in Apple’s own apps the top area is noticeably smaller and more compact. How can I achieve the same native look with ...
0
votes
1
answer
53
views
Floating button that shows on top of sheets?
I have the following code which shows a blue background and a persistent sheet that always shows.
In the top left, I want to add a back button that floats above BOTH the blue background and sheet, and ...
0
votes
0
answers
66
views
Strange background flicker when using .glassEffect in a horizontal ScrollView
I am trying to apply .glassEffect to some controls that are in a horizontal scroll view in a bottom .safeAreaBar.
No matter what I try, there is a persistent pesky flickering of the background that I ...
0
votes
1
answer
81
views
Segmented control has design bugs in Navigation Bar with Liquid Glass
When I put a SwifUI segmented control in a navigation bar, liquid glass seems to be making it render incorrectly. The capsule has vertical clipping and the sides show layered backgrounds.
Here is my ...
1
vote
1
answer
58
views
Coloring the SwiftUI Toggle in macOS26 no longer works
on macOS26 / 26.1 Tahoe the Toggle stopped being colored / tinted by using modifier
.tint(toggleColor())
it just remains with the current system color... e.g. blue or the tint central to the whole ...
2
votes
1
answer
91
views
Incorrect display of the TabBar when selecting a tab with scroll view inside
I'm trying to implement a tab bar on iOS 26 like the Music or Health apps on iPhone.
On a white background this is not noticeable, but when changing the background color to dark at the start of the ...
1
vote
0
answers
29
views
VideoPlayer not working from archived App [duplicate]
I setup a clean MacOS Tahoe (26.2) project with this code
import SwiftUI
import AVKit
@main
struct TestVideoApp: App {
let player = AVPlayer(url: URL(string: "https://www.w3schools.com/...
2
votes
1
answer
81
views
SwiftData update causes render with initial data overwriting changes
I'm working on a SwiftUI app using SwiftData, and I'm very new to both frameworks, and swift in general to be honest. I'm trying to create a webview that embeds a monaco editor that will then send the ...
0
votes
0
answers
63
views
How to implement long press (minimum duration) for iOS widget buttons?
I've seen apps that have interactive widget buttons where a short tap does nothing, but holding the button for at least 1 second executes the action. This can be configured per button in the widget ...
0
votes
0
answers
27
views
Swift can’t load resource folder at runtime (“No such file or directory”) even though files are added to Xcode [duplicate]
I'm building a macOS app in SwiftUI and I'm trying to load a folder called Wallpapers that I added to my Xcode project.
The folder contains subfolders (categories) and each category contains wallpaper ...
1
vote
0
answers
38
views
Custom UITabBar badge color ignored when switching to Map tab in iOS 18+
I found a reproducible issue in iOS 18+. When a SwiftUI TabView contains a Map (MKMapView), any custom UITabBarAppearance badge color is ignored while that tab is active. As soon as you switch to a ...
1
vote
1
answer
56
views
How to create a SwiftUI Menu with multiple Pickers without extra dividers?
I'm trying to create a SwiftUI Menu containing two Picker to control content and sort. However, I cannot replicate menu appearance shown in my reference screenshot.
No matter which approach I try, I ...
1
vote
2
answers
91
views
SwiftUI @FocusState doesn’t focus a desired TextField
I have a SwiftUI view with multiple TextFields and a @FocusState bound to my view model. I want the first field to automatically get focus whenever the view appears(when coming back from a SecondView)....
0
votes
1
answer
68
views
How to present app-wide alerts/sheets above existing sheets in SwiftUI (central presenter like UIKit)?
TL;DR: my app has some global alerts and modals (e.g. hints about trial limits, the in-app purchase screens, etc.) which should be available through out the app. In UIKit I could always present alerts ...
-2
votes
0
answers
56
views
Homography in soccer app not work properly [closed]
I'm having trouble calculating the inverse homography that would draw the players on the 2D pitch in the view.
The homography calculation seems perfect to me because the virtual pitch drawn on the ...
1
vote
1
answer
82
views
Pre-Selecting Values for a MultiDatePicker
Premise
I have a MultiDatePicker bounded to a closed range of the current month. In addition, I have a datePicker representing a "Start Date" that is the current day. I want the Day of the ...
1
vote
1
answer
82
views
How to dynamically update an existing AVComposition when users add a new custom video clip?
I’m building a macOS video editor that uses AVComposition and AVVideoComposition.
Initially, my renderer creates a composition with some default video/audio tracks:
@Published var composition: ...
2
votes
2
answers
68
views
Updating a property in @Observable ViewModel trigger a redraw of all Views using it
I’m using the @Observable, @Bindable in SwiftUI.
I have a simple ViewModel with two properties:
@Observable
final class AlarmLevelSetupViewModel {
var displayedValueLevel1: Decimal = 1
var ...
2
votes
1
answer
59
views
How to use NavigationStack with path and multiple enum type destinations in SwiftUI
I want to use NavigationStack with a custom navigation path array supporting multiple destination types. For example:
enum A: Hashable { ... }
enum B: Hashable { ... }
NavigationStack(path: $...
Advice
0
votes
5
replies
54
views
Strange behavior draggesture
I am exploring the use of drag gestures.
Below is a small test code to see what happens and because I want to know the location on the screen / map.
The first time I drag, it works fine, but when I ...
0
votes
0
answers
48
views
How do I create a Preview for a Scene?
The top level of my app looks like:
struct MyApp: App {
var body: some Scene {
DocumentGroup(newDocument: MyDocument()) { file in
MyContentView(document: file.$document)
...
0
votes
1
answer
75
views
How to use custom style for macOS app ToolbarItem (the sidebar toggle button)?
This is what I want to achieve for the sidebar toggle button:
When hovering:
When not hovering:
This is what I have now (macOS 26):
When hovering:
When not hovering:
I want to remove the border ...
0
votes
0
answers
32
views
SwiftUI arrow key keyboard shortcuts don't function for iPad
I would like to use the arrow keys as keyboard shortcuts in an app that I am building for iOS/iPadOS, for the sake of users with a hardware keyboard.
The following code works fine for iPhone, but not ...
0
votes
1
answer
63
views
Content of TabView is going beyond safe areas in the NavigationStack
import SwiftUI
struct OnboardingView: View {
@ObservedObject var viewModel: OnboardingViewModel
var body: some View {
TabView(selection: $viewModel.currentPage) ...
0
votes
0
answers
27
views
How to assign a different ModelContainer to @Query? [duplicate]
My application contains two different databases. The first contains information that does not change and will be distributed in the app's bundle. The second contains information that can be edited and ...
-3
votes
1
answer
50
views
Text Layout Inconsistency with maxHeight and fixedSize
I'm experiencing inconsistent layout behavior with SwiftUI Text when using maxHeight constraints combined with fixedSize().
I have a long text string that behaves differently depending on the ...
1
vote
2
answers
65
views
How do I extend the background of child views to their parent without using GeometryReader and without affecting the natural height in SwiftUI
As you can see in the image below, I want the left (star) and right (sun) views’ backgrounds to fill their parent (HStack) without using GeometryReader or altering the HStack’s natural height.
struct ...
2
votes
1
answer
109
views
Reloading another iOS widget's timeline from an AppIntent
I’m working with two iOS widgets (WidgetA and WidgetB) that both display the value of a flag stored in SwiftData. Each widget can update the flag by triggering an AppIntent when a button is pressed.
...
1
vote
0
answers
79
views
How to dynamically size TextEditor like TextField in SwiftUI
In SwiftUI, you can dynamically size a TextField like this which expands vertically as the user types.
TextField("Enter text", text: $text, axis: .vertical)
I would like to do the same thing ...
1
vote
1
answer
73
views
How to structure SwiftUI so that pages keep their state when switching between different UI layouts?
I have a SwiftUI view that switches between two completely different container layouts:
a TabView layout (for compact width)
a sidebar + content layout using HStack (for regular width). I am using a ...