Category "swiftui"

How to add polylines and annotations from user taps in SwiftUI

I am trying to drop annotations/pins wherever a user touches a certain location on the map. Whenever a user drops more 2 or more pins, it creates a polyline tha

Dismiss button in SwiftUI modal called from UIKit

I have got a SwiftUI modal view which I am calling from main UIKit view. I want to add a dismiss button to my modal view. As I can tell, there is no @State vari

Position view relative to a another centered view

Hello SwiftUI community, I'm trying to do something that's probably easy to do but I'm stuck on it since hours. In a list, I'd like to have items composed of:

Handling focus event changes on tvOS in SwiftUI

How do I respond to focus events on tvOS in SwiftUI? I have the following SwiftUI view: struct MyView: View { var body: some View { VStack {

Best Way to Update/Edit an Array Element in SwiftUI

I have an array of identifiable Training elements. Each Training element only has two properties, name and isRequired. What is the most straight-forward (Swif

How to create Generic if @EnvironmentObject?

I've recently come across the need to write a Mock of a Class, as it causes the SwiftUI preview from working. Unfortunately, I get the error: Property type 'T'

SwiftUI - Dynamic list of buttons in ActionSheet

I need to generate a dynamic list of buttons in an ActionSheet. Say I have an array of options ["Option1", "Option2"], how can I achieve this? .actionSheet(isP

WKWebView not showing Navigation Bar

I have a view in SwiftUI that shows a WKWebView which is passed to the main ContentView using the UIViewControllerRepresentable class, implemented following the

SwiftUI TapGesture onStart / TouchDown

I am using the TapGesture in SwiftUI for MacOS. TapGesture is only recognized on TouchInsideOut event, when releasing the press again. I want to call an action

SwiftUI chat app: the woes of reversed List and Context Menu

I am building a chat app in SwiftUI. To show messages in a chat, I need a reversed list (the one that shows most recent entries at the bottom and auto-scrolls t

SwiftUI popover background color

With UIKit, I could customize the background color of a popover using UIPopoverPresentationController's backgroundColor. This would change the color including

How can I make animation with CAEmitterLayer on SwiftUI?

How can I convert this code to SwiftUI. It's a snow effect. I used CAEmitterLayer but I don't know how to use it in SwfitUI. There is no addSublayer in SwiftUI.

How to get the index of a deleted row from a list in SwiftUI?

I want to delete an element from an array that I am displaying as a list using a ForEach, but I also need to send a HTTP request to a REST API and I need to put

How can I manage this view when constraints aren't available to me in swiftui?

I am very new to SwiftUI, and have actually been getting the hang of arranging my views using the Z, V and HStacks. But the lack of a centre anchor is proving d

SwiftUI edges visible after using overlay

I'm trying to create rounded edges in one of my views using overlay. .background(Color.gray.opacity(0.2)) .overlay( RoundedRectangle(cornerRadius: 10)

How can I present a small page sheet with SwiftUI?

I'm developing an app for iPad with SwiftUI. I want to present a page sheet but with a smaller size. I'm using but I can't change the width of the page sheet.

SwiftUI disable drag function

I have a simple view which contains a group of Buttons which allow drag feature depends on condition. How can i disable .onDrag based on the condition? The .dis

SwiftUI Get Coordinates of TextField or any View

I'm struggling to find a way in SwiftUI to get the x,y coordinates of the origin of a TextField (or any view). I can certainly provide a position or offset to m

QLPreviewController missing navigation bar in SwiftUI

QLPreviewController navigation bar missing when I presented in sheet. It looks like this : How can I show up top navigation bar or navigationItem? QuickLook

SwiftUI: How to center a view vertically and horizontally inside of a container view and put something under it

I searched stackoverflow, but unfortunately didn't find a solution to this particular case. I try to display following scenario: a container view a Text that