Questions tagged [swiftui-sheet]
The swiftui-sheet tag has no usage guidance.
51
questions
18
votes
4
answers
7k
views
SwiftUI: How to add a gray line bar on Sheet?
I know how to add this element with HStack and Rectangle. But...
How is it called?
Does SwiftUI have this element out of the box?
17
votes
5
answers
14k
views
Make sheet the exact size of the content inside
Let's say I have a custom view inside of a sheet, something like this
VStack {
Text("Title")
Text("Some very long text ...")
}
.padding()
.presentationDetents([.height(250)])
...
11
votes
1
answer
1k
views
SwiftUI sheets not correctly deinitializing associated instances
I’ve run into a puzzling behavior in SwiftUI related to sheet presentation. When dismissing a sheet, I noticed that associated instances (view models held by the sheet’s view) don’t seem to get ...
11
votes
0
answers
1k
views
SwiftUI Are Presentation Detents supported on iPad?
So I have a minimum target of iOS 16, am using .sheet() with .presentationDetents([.medium]) and it works fine on iOS (iPhone). But when I load it on iPadOS it's always a fullsized sheet, seemingly ...
10
votes
2
answers
5k
views
Allow user interaction in views behind a sheet in SwiftUI
Apple recently announced that half sheets will soon be feasible in SwiftUI with the addition of the
.presentationDetents(detents: Set<PresentationDetent>)
modifier.
Sadly, this still seems to ...
9
votes
2
answers
4k
views
Presenting a sheet view with NavigationStack in SwiftUI
I am trying to figure out if there is a way to open a sheet with the new NavigationStack in iOS 16, but can't seem to find a way.
So of cause, it's possible to open a sheet using:
.sheet(isPresented: $...
4
votes
1
answer
888
views
Sheet displayed several times in SwiftUI
Short description: in detailView I've got a List of a related entity. For each item, there's a button to open the edit sheet for this item.
List {
if (book.booksBorrowers != nil) {
ForEach (...
3
votes
2
answers
1k
views
SwiftUI .popover frame size incorrect
In iOS 16.4 we can now use .presentationCompactAdaptation(.none) in our .popover to achieve a true popover on iOS (compact screen sizes).
SomeView()
.popover(isPresented: $isPopoverOpen) {
...
3
votes
1
answer
550
views
Dismissed view empties before animation starts when using SwiftUI navigation in combination with TCA
We are struggling with SwiftUI navigation in combination with TCA and I am wondering is someone else did encounter similar issue.
The problem is that when we set parameters isPresented or isActive on ....
2
votes
2
answers
1k
views
SwiftUI: Make sheet show content header or complete content
I'd like to have a SwiftUI sheet that either shows the header or complete content.
Requiring iOS 16 is ok.
I already get the correct two measured heights a presentationDetents
import Foundation
import ...
2
votes
2
answers
2k
views
How to determine if a popover will be displayed as a popover or sheet in SwiftUI?
In SwiftUI when a popover is displayed, it will display as either a popover or sheet depending on the device (iPad or iPhone) and window space available.
Is there a correct heuristic to check if the ...
2
votes
0
answers
243
views
SWIFTUI - I have to show two sheets But With Different Presentation Detents
I have to show two sheets But With Different Presentation Detents
Explanation:
I have a parent view showing a sheet with 0.7 detents.
Parent.Sheet { parentContent.presentationDetents([.fraction(0.70)])...
2
votes
1
answer
283
views
How to apply .presentationBackground modifier to a second view in a sheet with NavigationLink?
Been searching around online for a while and can't seem to find an answer to help me with this problem, since the .presentationBackground modifier is so new.
Problem:
When applying the ....
1
vote
2
answers
412
views
Why can't I close a sheet view when in landscape?
When I create a .sheet view and turn the iPhone to landscape, I can't close it.
I tried swiping down from the top but the sheet is just stuck there.
Example code:
import SwiftUI
struct ContentView: ...
1
vote
1
answer
774
views
SwiftUI: How to scroll a list inside a sheet without dragging the sheet to the top
I have prepared a simple example. If you tap on the button, a sheet will be presented containing the CustomSheetView. Do not behalf on the design itself it is more about the scrolling behaviour. If I ...
1
vote
1
answer
162
views
SwiftUI Sheet Animation Issue with Non-Default Background Colors
I'm working on a SwiftUI project where I use a .sheet modifier to present a bottom drawer with two detent sizes: .medium and .large. The drawer contains a button that toggles its size between these ...
1
vote
2
answers
1k
views
SwiftUI: Logout and switch screens from a popover
In my app, I have a View which is set to either a login View or a home TabView, depending on if the user is logged in. From the TabView, the user can go to a profile popover and logout. I want to ...
1
vote
3
answers
3k
views
swiftui how to find out if a sheet is currently being presented
I have an app with many nested views, some which show a sheet based on a user action.
But I also have a sheet that I'd like to present on the main view based on a timer (ie, not a user action). But ...
1
vote
1
answer
311
views
Odd Behaviour: LazyVStack and Sheets on iOS 17
Some of my apps that use a LazyVStack and a sheet for detail views show an odd behaviour as of iOS 17 where the modal does not show on rows that are loaded lazily, i.e. that are not displayed ...
1
vote
1
answer
1k
views
iOS Sheet Detents (presentation detents) not working after updating from iOS 15 to iOS 16
I recently updated my SwiftUI project from iOS 15.3 to 16.4 (target iPhone only) and wanted to test the new feature of presentationDetents apple developer: presentation detents. It seems that this ...
1
vote
1
answer
280
views
NavigationLink or Sheet upon onTap Gesture
I am new in Swift, I am trying to build a test app in which I have people in a list, all works for inserting new people, I managed also swipe for delete, but I'm not able to find the right procedure ...
1
vote
1
answer
688
views
sheet can not be dismissed after an alert is displayed
I’m trying to show alerts in a sheet in SwiftUI. I have Cancel and Save buttons on the sheet and both of them are dismissed after the action is done.If there is an error on saving, an alert is pop ...
1
vote
0
answers
383
views
Sheet does not appear when triggered while menu is open in SwiftUI (and thereafter)
I seem to be using (context) menus incorrectly in SwiftUI (or there is a serious bug):
When a menu is open and the user taps another button (⛭) in the background that is supposed to open a sheet, the ...
1
vote
0
answers
857
views
How to make a sheet in swiftUI be the height of its content plus the keyboards height?
I am trying to build a sheet that has a textfield which (when focused) opens the keyboard and also has some further content as well. I want the presentationDetents from the sheet to be the height of ...
1
vote
0
answers
433
views
SwiftUI GeometryReader not working properly in sheet
I am trying to fit the size of a sheet to its content. There is another question on StackOverflow addressing this topic.
However the problem is that GeometryReader does not seem to work properly when ...
1
vote
0
answers
492
views
SwiftUI modal .sheet() or .fullScreenCover will not dismiss on iPad if initial attempt fails
I have a SwiftUI app with a .sheet() which includes in its View a ColorPicker plus a toolbar button that dismisses the sheet (either using dismiss() or setting binding to false).
On an iPhone ...
1
vote
0
answers
662
views
How to use NavigationLink inside SwiftUI sheet
I have 4 SwiftUI View:
The FirstView opens the SecondView using a sheet:
.sheet(isPresented: $showSheet) {
SecondView()
}
The SecondView opens the ThirdView using a sheet too:
...
1
vote
1
answer
1k
views
Body of a SwiftUI .sheet() is being evaluated after dismiss and not presenting
Use Case
If you have a SwiftUI ContentView() that displays a PausableView() based on a @State property presentSheet that is also used to present a .sheet(), the body gets evaluated differently based ...
0
votes
3
answers
47
views
How to change background color of bottom sheet?
I cannot use a ZStack to fill the color because by content inside a bottom sheet is a searchable view. Hence the header is showing the color of the sheet. Is there a way to change the color using ...
0
votes
1
answer
46
views
Set Sheet BackgroundColor Same As System BackgroundColor in macOS SwiftUI
Sheet background color looks perfectly fine(sheet background color sets system background color automatically)
Untill presented view has .white background color, then sheet background color becomes ...
0
votes
1
answer
75
views
My SwiftUI app does not dynamically populate the content of a pop-up View when the first button is pressed
I have a grid of small images/icons as buttons and a pop-up modal View. The modal view is meant to display a larger version of the image that was the button, and some information about it. However, in ...
0
votes
1
answer
670
views
SwiftUI Form: Sheet isn't dismissed automatically when the view it's attached to is gone
See the code below (BTW, List has the same issue):
enum Value: String, Equatable {
case a = "a"
case b = "b"
}
struct ContentView: View {
@State var value: Value = .a
...
0
votes
1
answer
1k
views
SwiftUI - Sheet doesn't work in Navigation View
Having issues with a NavigationView and Sheet.
I want to use not full-size sheet but bottom sheet and connect LoginView() and SignView() through sheet. At this time, frame of SignView never follow ...
0
votes
1
answer
687
views
SwiftUI using ForEach and onTapGesture to update selected element causing crash
I have some code that I am using, the idea is that the user selects a card they like and a sheet is presented to show more information about that card. The problem is, if I don't have the Text(...
0
votes
0
answers
49
views
Sheet binded item doesn't deinitialize SwiftUI
Have the following scenario. Basically I want to use the item binded sheet init and bind it to an optional property which will be set when we want to show the sheet. On the outside it looks perfectly ...
0
votes
1
answer
369
views
Custom bottom sheet container using SwiftUI
I'm trying to create a custom expandable view, something like on gif below:
I'm trying to use offsets for a container, but there is a problem with content, when the content is scrollable (like ...
0
votes
1
answer
49
views
Problem in view with sheet, button cannot be access
I created a view that has the sheet element and I disabled the option for it to be dismissed, but this led to the problem of the back button for the other view not being accessible.
image of my view
...
0
votes
3
answers
114
views
In SwiftUI, when the MyView popup sheet then dismissed, the MyView should be displayed instead of ListView
Here is three view,ContentView,ListView and MyView。Click first bottom icon show ListView,then click NavigationLink display MyView.Click the button display sheet,dismiss the sheet the ListView ...
0
votes
1
answer
49
views
Presenting Sheet reset the Selected Tab (SwiftUI)
Presenting sheet from childView of tabItem rerendering the whole Windows Group. My TabView alrdy has a selection Binding. When I use Fullscreen Cover it work fine. and sheet work fine with ...
0
votes
0
answers
25
views
Is there a way to make a half screen cover update a variable in another view in SwiftUI?
I've searched high and low for an answer to this. I have a variable called favoriteMustache in my signUp View. When a user clicks the mustache button, I want to show a half screen cover with a list of ...
0
votes
0
answers
68
views
open multiple sheet above others using item
in my app I'm using sheet with item, because I need to open multiple sheet in the view
in normal behavior everything is working fine as I only need one sheet once a time
but in one page I can open ...
0
votes
0
answers
133
views
SwiftUI: Custom .sheet modifier need to attach to top most window of app instead of View
I am aware about the importance of orders of modifiers in SwiftUI.
SwiftUI provides 2 special modifier interms of .alert(...) & .sheet(...). If these modifiers is attached from any down hierarchy ...
0
votes
0
answers
85
views
SwiftUI - How to show Custom Alert in middle of Screen from a half sized sheet
I am adding an overlay[alert] to very first parent View of the application.
I need to show this overlay from a sheet, but this overlay got covered by the sheet.
@main
struct ToastApp: App {
@State ...
0
votes
0
answers
180
views
BottomSheet Animation Delay
I am working on a bottom sheet for my code using the built in functionality of .sheet. Is there a way for you to disable the initial animation where it comes from the bottom and just have appear on ...
0
votes
1
answer
1k
views
How can I get a floating wheel date picker with SwiftUI?
I am trying to replicate this form I've found on the Health app:
It is a regular sheet. Inside the sheet, there is a Form. Then I use an HStack with Text with the label of the field and another Text ...
0
votes
0
answers
43
views
SwiftUI: Sheet dismissing returns to previous View, not current View
When Sheet is dismissed, screen returns to wrong View.
I'm currently facing some weird behavior that i can't seem to solve by myself. I have hierarchical structure where user can select one specific ...
0
votes
1
answer
571
views
SwiftUI - open sheet from various views
So I have a sheet like this
.sheet(item: $logMyPractice, content: { item in
AssesmentRecorderView(
assessment: DrillModel(
questions: [
.init(...
0
votes
1
answer
959
views
SwiftUI present sheet in a TabItem of TabView using presentationDetents
I am trying to create the same experience where a sheet is presented in one of the tab items of a TabView - not covering the tabs.
I am using .presentationDetents() and SwiftUI4.0 for that.
See ...
0
votes
0
answers
195
views
Bottom Sheet hide the toolbar bottom icons
I would like to know if there is any way with the bottom sheet SWIFTUI to build an app layout like Image Below, where a bottom sheet is displayed behind of a toolbar.
I want this Design
I tried to ...
0
votes
1
answer
640
views
SwiftUI: Using a Published attribute to displaying a sheet
Good evening!
I’m working on a simple project, where I have a view model, which has published boolean value. I would like to show a sheet when this value is set. However, the sheet function uses the ...