Category "swiftui"

SwiftUI .onTapGesture always higher priority than .swipeActions

How do I make my the code in .swipeActions be called instead of the one in .onTapGesture? I have a SwiftUI view like follows: struct ContentView: View {

Xcode 11 beta swift ui preview not showing

Just playing with Swift UI basic app and the preview canvas is not showing even though I'm in canvas mode. App runs, and I have this little snippet what am I mi

There doesn't appear to be support for UITabBar in SwiftUI. Workarounds?

SwiftUI doesn't appear to support UITabBar. How can I integrate that capability? Merely wrapping the view like one would a (eg) MKMapView, doesn't work because

How to change "Cancel" button text in modal sheet view in SwiftUI on watchOS 7?

I have 2 simple views: import SwiftUI struct ContentView: View { @State private var showingModalView = false var body: some View { Button(

Duplicate toolbar in SwiftUI

I added toolbar to 2 text fields, but the toolbar shows up twice: This is the code for my custom text field: public struct SUIDecimalField: View { public var

Custom back button for NavigationView's navigation bar in SwiftUI

I want to add a custom navigation button that will look somewhat like this: Now, I've written a custom BackButton view for this. When applying that view as l

How to print() to Xcode console in SwiftUI?

So I tried to put a print statement while debugging in a SwiftUI View. print("landmark: \(landmark)") In the following body. var body: some View { Navig

iOS SwiftUI: pop or dismiss view programmatically

I couldn't find any reference about any ways to make a pop or a dismiss programmatically of my presented view with SwiftUI. Seems to me that the only way is to

What is the difference between ObjectBinding and EnvironmentObject?

What is the purpose of @EnvironmentObject when we have @Binding property wrapper ? I am having trouble figuring out why @EnvironmentObject is needed. I took a l

Pull down to refresh data in SwiftUI

i have used simple listing of data using List. I would like to add pull down to refresh functionality but i am not sure which is the best possible approach. Pu

How to make a semi-transparent Navigation Bar in SwiftUI?

I've seen several posts discussing how to make a transparent Navbar in SwiftUI, but none on how to make a semi-transparent one, which is surprising to me as its

Dynamically Combining Currency Symbol to TextField Text

Is it possible to dynamically combine a currency symbol to some text before displaying it via TextField on a single text line? Currently my currency symbol is o

iOS 14 Medium Widget Size Background Image Refuses to Fill

For some reason I'm unable to get an image background to aspectFill correctly in XCode Version 12.0, but only on the .systemMedium widget size. It seems to work

How do I programmatically set secure text field and normal text field in swiftUI

SwiftUI has two different forms of text fields, one is SecureField which hides input and TextField which doesn't hide input. Instead of creating two separate vi

Open a FileDialog in SwiftUI on MacOs

In a SwiftUI app on MacOS I want to allow a users to select a file from the MacOS filesystem. I try to use AppKits NSOpenPanel . I tried like this, but I'm not

Using .searchable on a macOS causes the focus to always jump back to the search field

I'm trying to move away from having a TextField in the toolbar by using the new .searchable. But there seems to be a problem I can't solve. When you type the te

Run code during app launch in SwiftUI 2.0

In my App struct, I have a small function that checks to see if the user has opened the app before. If not, it shows an onboarding view with a few questions. Ri

TabView with "PageTabViewStyle" does not update it's content when @State var changes

I came across a weird Issue in SwiftUI. I created a simple View that only holds a Button and a TabView that uses the PageViewStyle. It seems that the TabView do

How to access NSWindow from @main App using only SwiftUI?

At this answer the solution work for Scene plus swiftUI. However using @main like: @main struct MyApp: App { @StateObject private var model = MyModel()

Xcode 13 UI Previews folder takes too much space

I have a 250Gb M1 Mac Mini and it is starting to run out of disk space recently, it seems like the UI Previews is the main culprit which takes roughly 165GB spa