Category "swiftui"

SwiftUI Can I use Binding get set custom binding with @Binding property wrapper?

How can I use Binding(get: { }, set: { }) custom binding with @Binding property on SwiftUI view. I have used this custom binding successfully with @State variab

SwiftUI DatePicker Binding optional Date, valid nil

I'm experimenting code from https://alanquatermain.me/programming/swiftui/2019-11-15-CoreData-and-bindings/ my goal is to have DatePicker bind to Binding<

How do I set the minimum window size with swiftUI, and how do I make the window use the specified size and position when launching?

I am making a macOS app with swiftUI. I want to set the minimum size of the window to 800, 500. Also there is this thing that if I close the window, and reopen,

SwiftUI inputAccesoryView Implementation

I am trying to implement an inputAccessoryView on a TextField in SwiftUI. The goal is to have a "Done" Button appear above the Keyboard which when pressed gets

How to implement a left or right DragGesture() that trigger a switch case in SwiftUI?

I have created a DragGesture in a View that should select a @State(Bool) whether the user swipe left or right. The thing is that only swiping right is detecte

NavigationLink onTapGesture and navigation not firing consistently

In a SwiftUI view I implemented a vertically scrolling list by creating a VStack that contains a NavigationView that contains some text. I build this by loopin

(SwiftUI) How to search using IGDB api, search in api

I need help I have app I'm using IGDB api and displaying games with no issue. I need ability to make user search and send the user text to api to display the ga

How can I remove Textfield focus when I press return or click outside Textfield? (SwiftUI, MacOS)

How can I remove Textfield focus when I press return or click outside Textfield? Note that this is SwiftUI on MacOS. If I do this: import SwiftUI struct Cont

GeometryReader in SwiftUI ScrollView causes weird behaviour and random offset

Im trying to create a ScrollView that in turn contains a GeometryReader (Explicitly not the other way around). The GeometryReader should contain an (image) with

Multiple sheet(isPresented:) doesn't work in SwiftUI

I have this ContentView with two different modal views, so I'm using sheet(isPresented:) for both, but as it seems only the last one gets presented. How could I

SwiftUI - How to disable sidebar from collapsing?

Gif to understand easier Is there any way to disable collapsibility of SidebarListStyle NavigationViews?

Animate a view to slide up and hide on tap in SwiftUI

I created a banner modifier that displays a banner from the top. This animates well. However, when I tap to dismiss it, it does not animate at all, just hides e

SwiftUI List Button with Disclosure Indicator

I have a SwiftUI view that consists of a list with some items. Some of these are links to other screens (so I use NavigationLink to do this) and others are acti

How to create TextField that only accepts numbers

I'm new to SwiftUI and iOS, and I'm trying to create an input field that will only accept numbers. TextField("Total number of people", text: $numOfPeople) T

Applying opacity to ZStack in SwiftUI

Here is my code of two overlapping rects, with opacity applied to them. var body: some View { let r = Rectangle() .foregroundColor(.blue) .f

Implement dark mode switch in SwiftUI App

I'm currently looking into Dark Mode in my App. While Dark Mode itself isn't much of a struggle because of my SwiftUI basis i'm struggling with the option to se

XCUITest ProgressView identifier hardcoded to "In progress" when within a Button

When creating a ProgressView and using .accessibilityIdentifier or a standard label, UI tests are able identify it. The view: ProgressView().accessibilityIdenti

SwiftUI TabView PageTabViewStyle prevent changing tab?

I have a TabView in SwiftUI in the PageViewTabStyle so i can swipe from page to page. I'd like to have a setting that "locks" the current view in place, so the

SwiftUI TabView PageTabViewStyle prevent changing tab?

I have a TabView in SwiftUI in the PageViewTabStyle so i can swipe from page to page. I'd like to have a setting that "locks" the current view in place, so the

Why am I getting "Instance method 'background(_:alignment:)' requires that 'UIColor' conform to 'View'"?

I would like to understand why am I having issue with the background()? Instance method 'background(_:alignment:)' requires that 'UIColor' conform to 'View' v